问题:为什么我的数据绑定文本不会呈现为文本
当我使用数据绑定TextBlock控件时,我的Windows应用程序中的输出显示为Squares,就像它无法弄清楚要将文本呈现为什么一样。如果我将实际文本放在Text属性中,它将正常显示。
<RelativePanel x:Name="BasicInfo" RightOf="ProfilePicture">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="FirstName" Text="{Binding FirstName}"
TextWrapping="NoWrap" Margin="10,0,0,0"/>
<TextBlock x:Name="LastName" Text="{Binding LastName}"
TextWrapping="NoWrap" Padding="3,0,0,0"/>
</StackPanel>
<TextBlock x:Name="EmailAddress" HorizontalAlignment="Left" Text="{Binding EmailAddress}"
TextWrapping="NoWrap" Margin="10,2,0,0" />
<TextBlock x:Name="PhoneNumber" HorizontalAlignment="Left" Text="{Binding PhoneNumber}"
TextWrapping="NoWrap" Margin="10,2,0,0" />
</StackPanel>
</RelativePanel>
<RelativePanel x:Name="AddressInfo" Below="BasicInfo" RightOf="ProfilePicture" Margin="0, 20, 0, 0">
<StackPanel Orientation="Vertical">
<TextBlock x:Name="Address1" HorizontalAlignment="Left" Text="{Binding Address1}"
TextWrapping="NoWrap" Margin="10,0,0,0"/>
<TextBlock x:Name="Address2" HorizontalAlignment="Left" Text="{Binding Address2}"
TextWrapping="NoWrap" TextAlignment="Left" Margin="10,0,0,0"/>
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="City" HorizontalAlignment="Left" Text="{Binding City}"
TextWrapping="NoWrap" Margin="10,0,0,0"/>
<TextBlock>,</TextBlock>
<TextBlock x:Name="State" Text="{Binding State}"
TextWrapping="NoWrap" Margin="3,0,0,0"/>
</StackPanel>
<TextBlock x:Name="ZipCode" HorizontalAlignment="Left" Text="{Binding ZipCode}"
TextWrapping="NoWrap" Margin="10,0,0,0"/>
</StackPanel>
</RelativePanel>
以下是输出结果:
答案 0 :(得分:0)
我们可以在xaml.cs页面中尝试
Dispatcher.BeginInvoke(delegate
{
listboxname.ItemsSource = Resultclassname;
});