FalseBeing 2016-07-13 08:53 采纳率: 0%
浏览 941

问题是我不知道为什么,前台ListView里不能够显示出来绑定的对象

我在学习Windows 10 通用应用开发时遇到了这个问题,自己解决不了,希望得到论坛里各位高手的帮助,我还是入门阶段。先谢谢各位了。代码在这里
前台XAML
x:Class="JustaTry.Controls.CountryNumberList"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:JustaTry.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="1920"
d:DesignWidth="1080">

<Popup Visibility="Visible">

        <ListView  Name="CountryNumberListView"  ScrollViewer.HorizontalScrollMode="Disabled" ScrollViewer.VerticalScrollMode="Auto"
                  Width="1080" Height="1920"
                  Tapped="CountryNumberListView_Tapped"
                  Visibility="Visible"
                  ItemsSource="{x:Bind CountryNumberSet}">
        <ListView.ItemTemplate>
            <DataTemplate>
                <StackPanel Orientation="Horizontal" Visibility="Visible">
                    <TextBlock Width="640" Height="160" Text="{Binding CountryNumber.Country}" FontSize="160"></TextBlock>
                    <TextBlock Width="440" Height="160" Text="{Binding CountryNumber.Number}" FontSize="160"></TextBlock>
                </StackPanel>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>

</Popup>

后台
namespace JustaTry.Controls
{
public sealed partial class CountryNumberList : UserControl
{
public CountryNumberList()
{
this.InitializeComponent();

        ObservableCollection<CountryNumber> CountryNumberSet = new ObservableCollection<CountryNumber>()
     {
     new CountryNumber() { Country = "中国", Number = "+86" },
     new CountryNumber() { Country = "美国", Number = "+86" },
     new CountryNumber() { Country = "英国", Number = "+86" },
     new CountryNumber() { Country = "法国", Number = "+86" },
     new CountryNumber() { Country = "荷兰", Number = "+86" }

     };


    }

    public void CountryNumberListView_Tapped(object sender, RoutedEventArgs e)
    {

    }
    public class CountryNumber
    {
        public String Country { get; set; }//默认为私有类,需要注意声明public
        public String Number { get; set; }
    }

    public ObservableCollection<CountryNumber> CountryNumberSet = new ObservableCollection<CountryNumber>();



}

}

  • 写回答

1条回答 默认 最新

  • 布鲁bool 2016-07-13 10:18
    关注

    你这用什么iDE开发的啊

    评论

报告相同问题?

悬赏问题

  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求
  • ¥20 antv g6 折线边如何变为钝角
  • ¥30 如何在Matlab或Python中 设置饼图的高度
  • ¥15 nginx中的CORS策略应该如何配置
  • ¥30 信号与系统实验:采样定理分析
  • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao