Windows Phone Toolkit How to get full Popup ListPicker?

核能气质少年 提交于 2020-01-06 02:22:24

问题


I am wondering how do you make it so the list picker goes to a separate screen when clicked on?

I tried

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

But that crashes the app saying it can't find PickerFullModeItemTemplate


回答1:


Did you provide a ressource named PickerFullModeItemTemplate ?

Your code specify two separate custom templates for each of the states (ItemTemplate and FullModeItemTemplate). Here is a very basic example.

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>

If you do not want to have custom templates then you can use a simple list of strings with the default ones

<toolkit:ListPicker ExpansionMode="FullScreenOnly"  x:Name="listPicker" Header="Header" FullModeHeader="Full mode Header"  CacheMode="BitmapCache"/>


来源:https://stackoverflow.com/questions/16924308/windows-phone-toolkit-how-to-get-full-popup-listpicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!