我使用以下xaml代码绑定带有联系人地址的列表框
<ListBox Name="ContactResultsDataLINQ" ItemsSource="{Binding}" Height="200" Margin="24,0,0,0" DataContext="{Binding}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Path=Addresses[0].PhysicalAddress.AddressLine1, Mode=OneWay}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
但是,这只会绑定AddressLine1 ...我想要它完整的地址= AddressLine1 + AddressLine2 + City
现在我如何通过xaml代码附加这些附加属性?
答案 0 :(得分:2)
使用两个TextBlock
元素,或使用Run
元素将其合并为一个元素。
<TextBlock>
<Run Text="{Binding Path=Addresses[0].PhysicalAddress.AddressLine1, Mode=OneWay}" />
<Run Text=" " />
<Run Text="{Binding Path=Addresses[0].PhysicalAddress.AddressLine2, Mode=OneWay}" />
<Run Text=" " />
<Run Text="{Binding Path=Addresses[0].PhysicalAddress.City, Mode=OneWay}" />
</TextBlock>