参数不正确,ListPicker Items Exception

发布于 2024-12-27 15:16:50 字数 2921 浏览 1 评论 0原文

当我尝试从 Windows Phone 7 应用程序页面中的 ListPicker 控件中选择一个项目时,我试图找出一个奇怪的异常的解决方案,该异常在运行时引发,该页面非常简单,包含非常基本的内容,异常消息is : 参数不正确,在 App_UnhandledException 事件处理程序中捕获, 这是我正在使用的xaml

        <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>

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

呆萌少年 2025-01-03 15:16:50

这是由 5 个 Items 的限制引起的,克服它的唯一方法是使用 ItemTemplate。您无法在工具包的 8 月版本中设置 ListPickerMode 和 ItemCountThreshold 属性。
如果添加 7 个项目,控件将切换到完整模式并将项目添加到完整模式弹出窗口的列表框中。这就是导致此问题的原因,唯一的解决方法是使用模板和绑定列表:/
-1 至 女士

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文