Can't populate a ListPicker

Timerever

Member
Dec 29, 2010
38
13
0
I'm not sure if this is right place to ask and if stuff like this gets anwsers here but I'm getting really frustrated by this issue I'm ahving and I'd like to get some help from you guys.
I'm trying to create a Silverlight Toolkit ListPicker to allow user to choose from a set of background colors, using the example on http://windowsphonegeek.com/articles/listpicker-for-wp7-in-depth I've done this so far but the list picker still shows nothing at all. Do you guys have any idea of what's wrong?

P.S.: The ideia is having a color picker just like the accent color picker in the theme section of the phone settings.

XAML Code with the templates and the listpicker control:
Code:
<Grid.Resources>
    <DataTemplate x:Name="PickerItemTemplate">
        <StackPanel Orientation="Horizontal">
            <Rectangle Fill="{Binding ColorBrush}" Width="34" Height="34"/>
            <TextBlock Text="{Binding ColorName}" Margin="12 0 0 0"/>
        </StackPanel>
    </DataTemplate>
    <DataTemplate x:Name="PickerFullModeItemTemplate">
        <StackPanel Orientation="Horizontal" Margin="16 21 0 20">
            <Rectangle Fill="{Binding ColorBrush}" Width="34" Height="34"/>
            <TextBlock Text="{Binding ColorName}" Margin="16 0 0 0" FontSize="43" FontFamily="{StaticResource PhoneFontFamilyLight}"/>
        </StackPanel>
    </DataTemplate>
</Grid.Resources>

<toolkit:ListPicker x:Name="listPicker" ItemTemplate="{StaticResource PickerItemTemplate}" FullModeItemTemplate="{StaticResource PickerFullModeItemTemplate}" Header="Colors" FullModeHeader="Colors" Margin="8,8,8,554" ExpansionMode="FullScreenOnly" ItemsSource="{Binding}"/>
And here is the code to populate it:
Code:
Public Class ListPickerSources
    Public ColorName As String
    Public ColorBrush As SolidColorBrush
End Class

[and then somewhere else]

Dim items As New List(Of ListPickerSources)
items.Add(New ListPickerSources With {.ColorName = "White", .ColorBrush = New SolidColorBrush(Colors.White)})
items.Add(New ListPickerSources With {.ColorName = "Blue", .ColorBrush = New SolidColorBrush(Colors.Blue)})
items.Add(New ListPickerSources With {.ColorName = "Brown", .ColorBrush = New SolidColorBrush(Colors.Brown)})
items.Add(New ListPickerSources With {.ColorName = "Gray", .ColorBrush = New SolidColorBrush(Colors.Gray)})
items.Add(New ListPickerSources With {.ColorName = "Green", .ColorBrush = New SolidColorBrush(Colors.Green)})
items.Add(New ListPickerSources With {.ColorName = "Magenta", .ColorBrush = New SolidColorBrush(Colors.Magenta)})
items.Add(New ListPickerSources With {.ColorName = "Orange", .ColorBrush = New SolidColorBrush(Colors.Orange)})
items.Add(New ListPickerSources With {.ColorName = "Purple", .ColorBrush = New SolidColorBrush(Colors.Purple)})
items.Add(New ListPickerSources With {.ColorName = "Red", .ColorBrush = New SolidColorBrush(Colors.Red)})
items.Add(New ListPickerSources With {.ColorName = "Yellow", .ColorBrush = New SolidColorBrush(Colors.Yellow)})
items.Add(New ListPickerSources With {.ColorName = "Black", .ColorBrush = New SolidColorBrush(Colors.Black)})
listPicker.ItemsSource = items
 
Last edited: