Windows Phone Toolkit如何获得完整的Popup ListPicker?

时间:2013-06-04 17:50:17

标签: windows-phone-7 silverlight-toolkit

我想知道你如何制作它,以便点击选择器进入单独的屏幕?

我试过

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

但是,该应用程序崩溃了,说找不到PickerFullModeItemTemplate

1 个答案:

答案 0 :(得分: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;

<强> XAML

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