Search code examples
c#silverlightxamlwindows-phone

The parameter is incorrect, ListPicker Items Exception


I'm trying to figure out a solution for a weird exception that raises at runtime when I try to select an item from a ListPicker control in a Windows Phone 7 Application page, the page is really simple and contains very basic stuff, the exception message is : The parameter is incorrect, it's caught at App_UnhandledException event handler, Here is the xaml I'm using

        <toolkit:ListPicker x:Name="lstColor" Grid.Row="3" >
            <toolkit:ListPicker.Items>
                <toolkit:ListPickerItem x:Name="Blue">
                    <StackPanel Orientation="Horizontal">
                        <Rectangle Fill="Blue" Width="40" Height="40"/>
                        <TextBlock Text="Blue" Margin="20,0"/>
                    </StackPanel>
                </toolkit:ListPickerItem>
                <toolkit:ListPickerItem x:Name="Grey">
                    <StackPanel Orientation="Horizontal">
                        <Rectangle Fill="Gray" Width="40" Height="40"/>
                        <TextBlock Text="Grey" Margin="20,0"/>
                    </StackPanel>
                </toolkit:ListPickerItem>
                <toolkit:ListPickerItem x:Name="Orange">
                    <StackPanel Orientation="Horizontal">
                        <Rectangle Fill="Orange" Width="40" Height="40"/>
                        <TextBlock Text="Orange" Margin="20,0"/>
                    </StackPanel>
                </toolkit:ListPickerItem>
                <toolkit:ListPickerItem x:Name="Pink">
                    <StackPanel Orientation="Horizontal">
                        <Rectangle Fill="Pink" Width="40" Height="40"/>
                        <TextBlock Text="Pink" Margin="20,0"/>
                    </StackPanel>
                </toolkit:ListPickerItem>
                <toolkit:ListPickerItem x:Name="Purple">
                    <StackPanel Orientation="Horizontal">
                        <Rectangle Fill="Purple" Width="40" Height="40"/>
                        <TextBlock Text="Purple" Margin="20,0"/>
                    </StackPanel>
                </toolkit:ListPickerItem>
                <toolkit:ListPickerItem x:Name="Red">
                    <StackPanel Orientation="Horizontal">
                        <Rectangle Fill="Red" Width="40" Height="40"/>
                        <TextBlock Text="Red" Margin="20,0"/>
                    </StackPanel>
                </toolkit:ListPickerItem>
                <toolkit:ListPickerItem x:Name="White">
                    <StackPanel Orientation="Horizontal">
                        <Rectangle Fill="White" Width="40" Height="40"/>
                        <TextBlock Text="White" Margin="20,0"/>
                    </StackPanel>
                </toolkit:ListPickerItem>
            </toolkit:ListPicker.Items>
        </toolkit:ListPicker>

Solution

  • This is caused by the limit of 5 Items, the only way to overcome it is to use an ItemTemplate. You cannot set the ListPickerMode and ItemCountThreshold properties in the August version of the toolkit. If you add 7 Items, the control will switch to full mode and add the items to the full mode popup's ListBox. This what causes this issue, the only work around is to use a template and a bound list :/ -1 to MS