Passing custom objects to UserControl via XAML binding

前端 未结 1 445
北荒
北荒 2021-01-22 17:06

What I\'m trying to do is create a UserControl to which I can pass an Address object. It seems that when I pass Address=\"{Binding Path=Person.Address}\" to the Us

相关标签:
1条回答
  • 2021-01-22 17:14

    In MainWindow.xaml :

    <local:AddressView DataContext="{Binding Path=Person.Address}" />
    

    and then in AddressView.xaml

    <TextBox Text="{Binding Path=Summary, Mode=OneWay}" IsReadOnly="True" />
    

    This displays the summary for me.

    0 讨论(0)
提交回复
热议问题