xamlwindows-phone-8listpicker

How to change listpicker dropdown ItemTemplate background?


I have a Windows Phone 8 listpicker that I'm trying to change the background color of, however, it only seems to change the item background and not the dropdown box background as you can see in the screen capture. The dropdown box seems to be binded to the WP8 theme. How can I change the background of the entire dropdown box and not just each individual item?

Listpicker.ItemTemplate

<toolkit:ListPicker x:Name="BackgroundListPicker" Background="Black" ItemsSource="{Binding BackgroundsList}">
<toolkit:ListPicker.ItemTemplate >
    <DataTemplate x:Name="BackgroundItemTemplate"  >
       <Grid HorizontalAlignment="Stretch" Background="Black" VerticalAlignment="Stretch" Margin="0,0,0,0">
         <StackPanel Orientation="Horizontal">
             <Image  Source="{Binding BackgroundThumb}" Width="30" Height="30" HorizontalAlignment="Left" />
             <TextBlock Text="{Binding BackgroundName}" Foreground="White"  Margin="12,0,0,0" HorizontalAlignment="Right"/>
         </StackPanel>
       </Grid>
   </DataTemplate>
  </toolkit:ListPicker.ItemTemplate>
 </toolkit:ListPicker>

Solution

  • So your issue was that you were attempting to apply an image to an item. When you needed to hit the control itself that the items populate via ItemsPresenter so by pulling out the default style template for the control, and either making a place to pass in your image for an instance, or placing one directly into the template itself. You get your resulting background image for the ListPicker background to fall behind the items populating it.

    Glad you found your remedy! Cheers.