试图获得的Windows Phone 8 ListPicker工作 [英] Trying to get a Windows Phone 8 ListPicker to work

查看:140
本文介绍了试图获得的Windows Phone 8 ListPicker工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该ListPicker功能,我可以点击它和全屏弹出窗口,但也有可供选择的方案。

The ListPicker functions, in that I can click on it and a full screen popup appears, but there are options to choose from.

我的XAML:

                <toolkit:ListPicker ExpansionMode="FullScreenOnly" FullModeHeader="Select Module" Name="modulePicker">
                    <toolkit:ListPicker.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <TextBlock Text="{Binding moduleNumber}"/>
                            </StackPanel>
                        </DataTemplate>
                    </toolkit:ListPicker.ItemTemplate>
                    <toolkit:ListPicker.FullModeItemTemplate>
                        <DataTemplate>
                            <StackPanel">
                                <TextBlock Text="{Binding moduleNumber}"/>
                            </StackPanel>
                        </DataTemplate>
                    </toolkit:ListPicker.FullModeItemTemplate>
                </toolkit:ListPicker>

和其背后的C#包括:

String[] moduleNumber = { "AA1", "AA2", "AA3" };

    public MainPage()
    {
        InitializeComponent();
        this.modulePicker.ItemsSource = moduleNumber;
    }

那么,我需要做的就是在moduleNumber列出的字符串显示在ListPicker?

So what do I need to do to get the strings listed in moduleNumber to display on the ListPicker?

如果您需要了解更多的只是问问。

If you need to know more just ask.

推荐答案

后面的代码是好的。这是一个XAML的问题。试试这个办法而不是在你的XAML文件。

The code behind is fine. This is a xaml issue. Try this approach instead in your xaml file.

1)定义其绑定到从后面的代码moduleNumber阵列数据模板作为的PhoneApplicationPage资源。

1) Define your data templates as PhoneApplicationPage Resources which bind to the moduleNumber array from the code behind.

2)然后绑定列表选择器模板

2) Then bind your list picker to the templates.

<phone:PhoneApplicationPage.Resources>
    <DataTemplate x:Name="modulePickerItemTemplate">
        <StackPanel>
            <TextBlock Text="{Binding moduleNumber}"/>
        </StackPanel>
    </DataTemplate>
    <DataTemplate x:Name="modulePickerFullItemTemplate">
        <StackPanel>
            <TextBlock Text="{Binding moduleNumber}"/>
        </StackPanel>
    </DataTemplate>
</phone:PhoneApplicationPage.Resources>


<toolkit:ListPicker ExpansionMode="FullScreenOnly" FullModeHeader="Select Module" 
                    Name="modulePicker"
                    FullModeItemTemplate="{Binding modulePickerFullItemTemplate}" 
                    ItemTemplate="{Binding modulePickerItemTemplate}" />

这篇关于试图获得的Windows Phone 8 ListPicker工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆