How to add text to a WPF Label in code?

前端 未结 6 682
耶瑟儿~
耶瑟儿~ 2020-12-02 16:32

I feel stupid but cannot find out how to add a text to a WPF Label control in code. Like following for a TextBlock:

DesrTextBlock.Text = \"some text\";
         


        
6条回答
  •  鱼传尺愫
    2020-12-02 16:43

    In normal winForms, value of Label object is changed by,

    myLabel.Text= "Your desired string";
    

    But in WPF Label control, you have to use .content property of Label control for example,

    myLabel.Content= "Your desired string";
    

提交回复
热议问题