1

我想知道您是如何做到的,以便在单击列表选择器时转到单独的屏幕?

我试过了

    <toolkit:ListPicker  Margin="155,109,179,0" VerticalAlignment="Top" ItemTemplate="{StaticResource PriceTypesTemplate1}" ItemsSource="{Binding PriceTypes}" FullModeItemTemplate="{StaticResource PickerFullModeItemTemplate}"/>

但这会使应用程序崩溃,说它找不到PickerFullModeItemTemplate

4

1 回答 1

1

您是否提供了一个名为 的资源PickerFullModeItemTemplate

您的代码为每个状态(ItemTemplate 和 FullModeItemTemplate)指定两个单独的自定义模板。这是一个非常基本的例子。

C#

public class Cities
{
    public string Name { get; set; }
    public string Country { get; set; }
    public string Language { get; set; }
}
List<Cities> source = new List<Cities>();
source.Add(new Cities() { Name = "Madrid", Country = "ES", Language = "Spanish" });
source.Add(new Cities() { Name = "Las Vegas", Country = "US", Language = "English" });
source.Add(new Cities() { Name = "London", Country = "UK", Language = "English" });
source.Add(new Cities() { Name = "Mexico", Country = "MX", Language = "Spanish" });
this.listPicker.ItemsSource = source;

xml

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <Grid.Resources>
            <DataTemplate x:Name="PickerItemTemplate">
                <StackPanel Orientation="Horizontal">
                    <Border Background="LightGreen" Width="34" Height="34">
                        <TextBlock Text="{Binding Country}" FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Border>
                    <TextBlock Text="{Binding Name}" Margin="12 0 0 0"/>
                </StackPanel>
            </DataTemplate>
            <DataTemplate x:Name="PickerFullModeItemTemplate">
                <StackPanel Orientation="Horizontal" Margin="16 21 0 20">
                    <TextBlock Text="{Binding Name}" Margin="16 0 0 0" FontSize="43" FontFamily="{StaticResource PhoneFontFamilyLight}"/>
                    <TextBlock Text="language: "/>
                    <TextBlock Text="{Binding Language}" Foreground="Green"/>
                </StackPanel>
            </DataTemplate>
        </Grid.Resources>

        <toolkit:ListPicker ExpansionMode="FullScreenOnly"  x:Name="listPicker" ItemTemplate="{StaticResource PickerItemTemplate}"    FullModeItemTemplate="{StaticResource PickerFullModeItemTemplate}"  Header="Cities" FullModeHeader="Cities"  CacheMode="BitmapCache"/>
    </Grid>

如果您不想拥有自定义模板,那么您可以使用带有默认字符串的简单字符串列表

<toolkit:ListPicker ExpansionMode="FullScreenOnly"  x:Name="listPicker" Header="Header" FullModeHeader="Full mode Header"  CacheMode="BitmapCache"/>
于 2013-06-04T19:24:51.520 回答