public Counter(TextBox InputTextbox, Label CounterLabel) { int NB; var tempText = InputTextbox.Text; NB = (InputTextbox.MaxLength - tempText.Length); CounterNumber counterNumber = new CounterNumber { Number = NB.ToString() }; CounterLabel.Content = counterNumber; if (NB == 0) { CounterLabel.Foreground = new SolidColorBrush(Colors.Red); } }