Cannot correctly populate ListPicker control with Image and Name

前端 未结 2 989
日久生厌
日久生厌 2021-01-23 16:05

I have created a ListPicker control for a user to change his or her background, but not all of the information is populated correctly in the ListPicker control. The problem aris

相关标签:
2条回答
  • 2021-01-23 16:40

    Since you get the large list of items in the ListPicker, you need to create a template for it too. You only have the ItemTemplate at the moment. The property is called FullModeItemTemplate and the example of how to do that is shown here:

    http://windowsphonegeek.com/articles/listpicker-for-wp7-in-depth

    0 讨论(0)
  • 2021-01-23 16:45

    I ended up using the FullModeItemTemplate so that the the ListPicker would populate correctly in another page.

    SettingsPage.xaml

    <Grid.Resources>
    
                            <DataTemplate x:Name="PickerItemTemplate">
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="{Binding Image}" Width="50" Height="37.59" Margin="0,0,12,0"/>
                                    <TextBlock Text="{Binding Name}" TextWrapping="Wrap"/>
                                </StackPanel>
                            </DataTemplate>
    
                            <DataTemplate x:Name="PickerFullModeItemTemplate">
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="{Binding Image}" Width="50" Height="37.59" Margin="0,0,12,0"/>
                                    <TextBlock Text="{Binding Name}" TextWrapping="Wrap"/>
                                </StackPanel>
                            </DataTemplate>
    
                        </Grid.Resources>
    
    <toolkit:ListPicker x:Name="ThemeListPicker" Header="Theme" Grid.Row="2" Grid.ColumnSpan="2"
                                            FullModeItemTemplate="{StaticResource PickerFullModeItemTemplate}"
                                            ItemTemplate="{StaticResource PickerItemTemplate}"
                                            SelectedIndex="{Binding}"
                                            SelectionChanged="ThemeListPicker_SelectionChanged"/>
    
    0 讨论(0)
提交回复
热议问题