How to get contacts address from Contacts.SearchAsync results?

大兔子大兔子 提交于 2019-12-11 18:14:52

问题


I am binding a listbox with contacts address using following xaml code

<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>

However, this only binds AddressLine1...what i want it complete address = AddressLine1 + AddressLine2 + City

Now how do i append this additional properties via xaml code ?


回答1:


Either use two TextBlock elements, or combine it in a single, using Run elements.

<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>


来源:https://stackoverflow.com/questions/7945374/how-to-get-contacts-address-from-contacts-searchasync-results

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!