WPF: Binding a Label to a class property

后端 未结 2 622
心在旅途
心在旅途 2021-02-04 00:05

I\'m trying to get the content of a label to bind to the string property of a class instance without much success.

XAML:



        
2条回答
  •  天涯浪人
    2021-02-04 00:13

    Or give your Window a name: like NameOfWindow and use a ElementName binding:

    Content="{Binding ElementName=NameOfWindow, Path=MyFoo.W1}"
    

    Complete sample XAML:

        
            
         
    

提交回复
热议问题