System.Exception{System.ArgumentException}值不在预期范围内



每当我试图访问应用程序中的m列表选择器控件时,都会遇到此异常。

+       this    {App_name.App}  App_name.App
+       sender  {App_name.App}  object {App_name.App}
-       e   {System.Windows.ApplicationUnhandledExceptionEventArgs} System.Windows.ApplicationUnhandledExceptionEventArgs
+       base    {System.Windows.ApplicationUnhandledExceptionEventArgs} System.EventArgs {System.Windows.ApplicationUnhandledExceptionEventArgs}
+       ExceptionObject {System.ArgumentException: Value does not fall within the expected range.}  System.Exception {System.ArgumentException}
Handled false   bool
+       Non-Public members      

我的列表选择器的代码是

<ListBox Margin="0,417,0,0">
<ListBoxItem>
<toolkit:ListPicker Name="LearnerFileChooser" Width="431" >
<toolkit:ListPickerItem Content="A" />
<toolkit:ListPickerItem Content="B" />
<toolkit:ListPickerItem Content="C" />
<toolkit:ListPickerItem Content="E" />
<toolkit:ListPickerItem Content="F" />
<toolkit:ListPickerItem Content="G" />
<toolkit:ListPickerItem Content="H" />
</toolkit:ListPicker>
</ListBoxItem>

如果我将项目数量减少到4,那么它可以正常工作,但它在超过4个项目时崩溃。

我正在尝试创建一个字母表列表,用户可以从中进行选择。

这是一个已知的问题。

您必须绑定项目才能使用5个以上。

Codeplex:解析

ListPicker作为ItemsControl,将其Items属性设置为列表的ListPickerItems。ListPickerItems是UI元素,并且ListPicker在其呈现器中呈现它们。当有5或项目较少时,在当前页面上打开展开模式,您可以查看演示者中的所有项目。

但是,当存在6个或更多项目时,打开列表选择器将转到打开新页面的完整模式。这个新页面有一个列表框将其items属性设置为列表选择器的项。这就是它坏了。通过将列表框的项目设置为列表选择器的项目(在本例中是listpickeritems的列表),列表框将UIElements。现在,一个列表框项目包含在两个列表框中位置。

由于这个问题,ListPicker只支持数据绑定和模板化。不要将ListPicker的项设置为特定的UIElements。

相关内容

最新更新