如何在Windows Phone 7应用程序的列表框中显示完整数据

巴库

我正在为Windows Phone 7构建一个应用程序,其中有一个列表框,其中显示了来自Web服务的数据。我想在列表框中显示完整的数据。我正在使用textwrapping进行包装,但仍未显示数据。超出屏幕的数据不会显示。此外,我希望如果有人单击列表框中的项目,则将其导航到新页面。我可以使用列表框中的按钮来做到这一点,但我不想使用按钮。请看看我的xaml并尝试解决我的问题。

Xml:

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

评论部分是按钮,使用该按钮我可以导航,但无需使用按钮也可以导航

FunksMaName

我认为您的结构看起来有点复杂:下面的代码行得通吗?

<ListBox Name="CityList" BorderThickness="0" 
             Height="600" VerticalAlignment="Bottom" 

              Foreground="Black" 
              Background="AntiqueWhite" Grid.Row="1">

            <ListBox.ItemTemplate>
                <DataTemplate>
                    <!--      <Button IsHitTestVisible="False" BorderThickness="0">
        <Button.Content>-->

                    <Grid Tap="ShowState">

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="200" />
                            <ColumnDefinition Width="10" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <Image Grid.Column="0" Source="http://static.bbci.co.uk/frameworks/barlesque/2.60.3/orb/4/img/bbc-blocks-dark.png" 
                           HorizontalAlignment="Stretch" 
                           VerticalAlignment="Stretch" 
                           Margin="0,0,20,10" Height="100" Width="145" />
                        <StackPanel Grid.Column="2">
                            <TextBlock Text="{Binding city_name}"
                                       Foreground="Red" 
                                       FontFamily="Verdana" TextWrapping="Wrap" />

                            <TextBlock Text=", " Foreground="Red" FontFamily="Verdana" />
                            <TextBlock Text="{Binding state}" Foreground="Red" TextWrapping="Wrap"
                          FontFamily="Verdana" />

                            <TextBlock Text="{Binding city_description}" 
                                   TextWrapping="Wrap" Foreground="Black" FontFamily="Verdana" Margin="10,0,10,10" />
                        </StackPanel>
                    </Grid>


                </DataTemplate>
            </ListBox.ItemTemplate>

        </ListBox>

假设你有

public class CityListData
{
    public string city_name { get; set; }
    public string state { get; set; }
    public string city_description { get; set; }
}

您的代码背后

private void ShowState(object sender, GestureEventArgs e)
    {
        var control = sender as Grid;

        if (control != null)
        {
            var entity = (CityListData) control.DataContext;
            MessageBox.Show("You clicked on the state " + entity.city_name);
        }
    }

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何在Windows Phone中使用C#在列表框中显示完整数据

来自分类Dev

即使在mvvm Windows Phone应用程序中返回后,列表框也会突出显示选定的项目

来自分类Dev

在Windows Phone 7应用程序中添加搜索框

来自分类Dev

如何在Windows Phone中显示数据列表

来自分类Dev

如何在Windows Phone 7中显示Json数据

来自分类Dev

如何在Windows Phone 8应用程序中解决此应用栏显示问题?

来自分类Dev

列表框数据绑定Windows Phone

来自分类Dev

如何在ac#Windows窗体应用程序的列表框中显示结构的内容

来自分类Dev

如何在ac#Windows窗体应用程序的列表框中显示结构的内容

来自分类Dev

如何在Windows Phone 7的列表框中使用Web浏览器?

来自分类Dev

如何在Windows Phone 8的字符串数组中的每个列表框项目上应用背景色?

来自分类Dev

如何在Windows Phone 8的字符串数组中的每个列表框项目上应用背景色?

来自分类Dev

如何在Windows Phone 8.1(RT)应用程序中显示动画GIF?

来自分类Dev

如何在Windows Phone应用程序中的简单StackPanel中虚拟化数据

来自分类Dev

如何在Windows Phone 7和8中获取应用程序状态事件?

来自分类Dev

如何在Windows Phone 7应用程序开发中制作自定义文本块

来自分类Dev

Windows Phone 8中未显示列表框数据和图像

来自分类Dev

Windows Phone 8中未显示列表框数据和图像

来自分类Dev

Windows Phone 7-从列表框中传递/传输所选数据

来自分类Dev

如何在Ubuntu中挂载Windows Phone?

来自分类Dev

如何在Windows Phone 8中制作不可滚动的列表框

来自分类Dev

如何在Windows Phone 8中使用没有列表框的xml文件?

来自分类Dev

如何在Windows Phone绑定中从列表框获取值?

来自分类Dev

如何在Windows Phone绑定中从列表框获取值?

来自分类Dev

如何在Windows Phone 7应用程序开发的应用程序栏中添加超过4个图标

来自分类Dev

如何在Windows Phone 8应用中显示帮助

来自分类Dev

如何在Windows Phone 8.1中显示分组标题列表?

来自分类Dev

如何在Windows Phone 7应用中添加微调器

来自分类Dev

如何在Windows Phone 8.1(WinJS)应用程序中隐藏应用程序栏?

Related 相关文章

  1. 1

    如何在Windows Phone中使用C#在列表框中显示完整数据

  2. 2

    即使在mvvm Windows Phone应用程序中返回后,列表框也会突出显示选定的项目

  3. 3

    在Windows Phone 7应用程序中添加搜索框

  4. 4

    如何在Windows Phone中显示数据列表

  5. 5

    如何在Windows Phone 7中显示Json数据

  6. 6

    如何在Windows Phone 8应用程序中解决此应用栏显示问题?

  7. 7

    列表框数据绑定Windows Phone

  8. 8

    如何在ac#Windows窗体应用程序的列表框中显示结构的内容

  9. 9

    如何在ac#Windows窗体应用程序的列表框中显示结构的内容

  10. 10

    如何在Windows Phone 7的列表框中使用Web浏览器?

  11. 11

    如何在Windows Phone 8的字符串数组中的每个列表框项目上应用背景色?

  12. 12

    如何在Windows Phone 8的字符串数组中的每个列表框项目上应用背景色?

  13. 13

    如何在Windows Phone 8.1(RT)应用程序中显示动画GIF?

  14. 14

    如何在Windows Phone应用程序中的简单StackPanel中虚拟化数据

  15. 15

    如何在Windows Phone 7和8中获取应用程序状态事件?

  16. 16

    如何在Windows Phone 7应用程序开发中制作自定义文本块

  17. 17

    Windows Phone 8中未显示列表框数据和图像

  18. 18

    Windows Phone 8中未显示列表框数据和图像

  19. 19

    Windows Phone 7-从列表框中传递/传输所选数据

  20. 20

    如何在Ubuntu中挂载Windows Phone?

  21. 21

    如何在Windows Phone 8中制作不可滚动的列表框

  22. 22

    如何在Windows Phone 8中使用没有列表框的xml文件?

  23. 23

    如何在Windows Phone绑定中从列表框获取值?

  24. 24

    如何在Windows Phone绑定中从列表框获取值?

  25. 25

    如何在Windows Phone 7应用程序开发的应用程序栏中添加超过4个图标

  26. 26

    如何在Windows Phone 8应用中显示帮助

  27. 27

    如何在Windows Phone 8.1中显示分组标题列表?

  28. 28

    如何在Windows Phone 7应用中添加微调器

  29. 29

    如何在Windows Phone 8.1(WinJS)应用程序中隐藏应用程序栏?

热门标签

归档