xaml – Windows Phone Toolkit ListPicker引发未处理的异常
我正在开发
Windows Phone 8应用程序.我的应用程序使用Tookit中的ListPicker.我的代码如下所示:
<toolkit:ListPicker x:Name="myListPicker" Margin="12,-6,12,-2" Loaded="myListPicker_Loaded"> <toolkit:ListPicker.Items> <!-- Items are defined here --> </toolkit:ListPicker.Items> </toolkit:ListPicker> private void myListPicker_Loaded(object sender,RoutedEventArgs e) { if ((myListPicker != null) && (viewModel != null)) { } } 每当项目总数超过某个阈值时,我的应用程序就会抛出System.ArgumentException.我知道这个,因为我有以下代码: private void Application_UnhandledException(object sender,ApplicationUnhandledExceptionEventArgs e) { MessageBox.Show(e.ExceptionObject.Message + "nnExceptionn" + e.ExceptionObject.GetType().FullName + "n" + e.ExceptionObject.StackTrace); if (Debugger.IsAttached) { // An unhandled exception has occurred; break into the debugger Debugger.Break(); } } 消息称“价值不在预期范围内”.据我所知,当ListPicker需要进入全屏模式时会发生这种情况.我无法弄清楚为什么会发生这种情况. 有没有人有任何见解? 解决方法
看起来,在全屏模式下,您无法将ListPicker的项目设置为xaml页面中的特定UI元素.您必须绑定它们或使用模板.
在遇到这个问题之后,我在这里找到了一个解释:http://silverlight.codeplex.com/workitem/9412
我设法让我的解决方案正在做这样的事情: <toolkit:ListPicker x:Name="myListPicker" Margin="12,-2" Loaded="myListPicker_Loaded"> <toolkit:ListPicker.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Name}" Tag="{Binding ID}"/> </DataTemplate> </toolkit:ListPicker.ItemTemplate> <toolkit:ListPicker.FullModeItemTemplate> <DataTemplate> <TextBlock Text="{Binding Name}" Tag="{Binding ID}"/> </DataTemplate> </toolkit:ListPicker.FullModeItemTemplate> </toolkit:ListPicker> private void myListPicker_Loaded(object sender,RoutedEventArgs e) { if ((myListPicker != null) && (viewModel != null)) { myListPicker.ItemsSource = _Data; //_data is an array of objects with 2 properties named ID & Name } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- windows – 与findstr.exe进行逻辑OR比较
- windows – 如何找出创建文件的内容?
- windows – 使用两个网络适配器为特定网络适配器设置静态路
- .net – 创建MSI的最佳工具
- winapi – Windows SDK 7.0的signtool中的signwizard发生了
- 将同一台计算机重新加入Windows域,无需域管理员权限
- batch-file – 在DOS批处理不工作中比较2个数字
- 在Windows server2008中搭建sqli-lab实验环境
- windows – 并行端口阻塞
- windows-server-2008 – 为文件服务器运行Windows 7是否可以
- Windows Server 2016-清理残留域控信息
- 在Windows上使用git时出现警告和致命错误?
- 解决windows64位系统上安装mysql-python报错
- CreateWindowEx failed (当前程序已使用了 Windo
- windows-server-2008-r2 – netsh设置多个hosted
- Win2008 Server配置PHP环境 Win2008
- wix – 创建一个msi包,它在一台机器上安装32位和
- 命令行 – Microsoft Visual Studio 2012非常小的
- 利用开机账户登录“轻松访问”创建Windows后门
- 在Windows中没有回车符(CR)的情况下将新行打印到