WPF: reverting brush to default/original

前端 未结 5 821
不知归路
不知归路 2021-02-05 03:10

I\'m a complete newbie at WPF.

At the moment I\'m making a usercontrol for form elements called \"LabeledTextbox\" which contains a label, a textbox and a textblock for

5条回答
  •  鱼传尺愫
    2021-02-05 03:20

    Does this work? Setting it to black is better than using the ClearValue method

    public string ErrorMessage
    {
        set
        {
            if (string.IsNullOrEmpty(value))
            {
                _textbox.Background = Brushes.Black;
            }
            else
            {
                _textbox.Background = Brushes.Red;
            }
    
            _errorMessage.Text = value;
        }
    }
    

提交回复
热议问题