【发布时间】:2014-03-10 09:24:57
【问题描述】:
我正在为 windows phone 7 构建一个应用程序,其中我有一个列表框,我在其中显示来自 web 服务的数据。我想在我的列表框中显示完整的数据。我正在使用 textwrapping 来换行,但它仍然没有显示数据。超出画面的数据不显示。此外,我希望如果有人单击列表框中的项目,它将导航到新页面。我可以使用列表框中的按钮来做到这一点,但我不想使用按钮。请查看我的 xaml 并尝试解决我的问题。
Xaml:
<ListBox Name="CityList" BorderThickness="0"
Height="650" VerticalAlignment="Bottom"
SelectionChanged="CityList_SelectionChanged" Foreground="Black"
Background="AntiqueWhite" Grid.Row="1">
<ListBox.ItemTemplate>
<DataTemplate>
<!--<Button IsHitTestVisible="False" BorderThickness="0">
<Button.Content>-->
<ScrollViewer HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Disabled"
Height="80" Width="800">
<StackPanel Orientation="Horizontal"
Margin="0,0,10,10"
Background="AntiqueWhite"
Width="2000">
<Image Source="{Binding ImageBind }"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Margin="0,0,20,10" Height="100"
Width="145" />
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding city_name}"
Foreground="Red"
FontFamily="Verdana" />
<TextBlock Text=", " Foreground="Red" FontFamily="Verdana" />
<TextBlock Text="{Binding state}" Foreground="Red"
FontFamily="Verdana" />
</StackPanel>
<TextBlock Text="{Binding Path=city_description}"
TextWrapping="Wrap" Foreground="Black" FontFamily="Verdana" Margin="10,0,10,10">
</TextBlock>
</StackPanel>
</StackPanel>
</ScrollViewer>
<!--</Button.Content>
</Button>-->
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
注释部分是按钮,使用时我可以导航,但不使用按钮也可以导航
【问题讨论】:
-
Width="800"是问题所在。
标签: c# xaml windows-phone-7 listbox