windows-phone-8 - 未使用 Windows Phone 8 Listpicker ItemTemplate

标签 windows-phone-8 listpicker

我在页面中有一个 Listpicker 控件,我绑定(bind)了一些项目,我正在尝试更改项目模板。

我的模板如下所示:

<phone:PhoneApplicationPage.Resources>
    <DataTemplate x:Name="modulePickerFullItemTemplate">
        <StackPanel>
            <TextBlock Text="{Binding modes}"/>
        </StackPanel>
    </DataTemplate>
    <DataTemplate x:Name="modulePickerItemTemplate">
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="LALA" Foreground="#333"/>
            </StackPanel>
        </DataTemplate>
</phone:PhoneApplicationPage.Resources>

列表选择器:

<toolkit:ListPicker x:Name="ddlMode" Grid.Row="6" ExpansionMode="FullScreenOnly"
                    FullModeItemTemplate="{Binding modulePickerFullItemTemplate}" 
                    ItemTemplate="{Binding modulePickerItemTemplate}"  
                    FullModeHeader="Select mode">
</toolkit:ListPicker>

我在项目中看到的是我绑定(bind)到列表选择器的值,而不是我期望的 LALA 值。

我做错了什么吗?

最佳答案

你用过

ItemTemplate="{Binding modulePickerItemTemplate}"

在你的第一个代码片段中,但它必须是

ItemTemplate="{StaticResource modulePickerItemTemplate}"

您应该使用“Binding”来访问绑定(bind)到控件的数据,使用“StaticResource”来访问您在资源中定义的所有内容,例如 DataTemplate。

关于windows-phone-8 - 未使用 Windows Phone 8 Listpicker ItemTemplate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19469987/

相关文章:

javascript - localStorage 不适用于 IE 10 抛出错误

c# - HttpClient GetAsync挂起

c# - 自定义 CompositeCollection 不工作

windows-phone-7 - 如何在wp7中使用列表选择器selectionChanged事件

c# - 如何获取 ListPicker 的选中项

c# - 如何设置 SelectionMode 为 multiple 的 Listpicker 项目

windows-phone-7 - 列表选择器和 "SelectedItem must always be set to a valid value"

c# - WP7 上 ListPicker 的 caliburn.micro 绑定(bind)约定

c# - 如何查看元素在屏幕中是否可见?

c# - ISupportIncrementalLoading 在离开后不会停止