数据绑定 – 数据绑定0x8000ffff上的wp7奇怪UnhandledException
发布时间:2020-12-14 02:26:12 所属栏目:Windows 来源:网络整理
导读:我在数据绑定期间遇到一个奇怪的未处理异常.我将ListBox与IList数据绑定.在使用对象填充列表后,我将ListBox的DataContext设置为我的对象: IListUsers users = new ListUsers;foreach(JToken jresult in Users){User juser = JsonConvert.DeserializeObjectU
我在数据绑定期间遇到一个奇怪的未处理异常.我将ListBox与IList数据绑定.在使用对象填充列表后,我将ListBox的DataContext设置为我的对象:
IList<Users> users = new List<Users>; foreach(JToken jresult in Users) { User juser = JsonConvert.DeserializeObject<User>(jresult.ToString()); users.Add(juser); this.DataContext = myObject; 我的对象只有两个字段,名称和电子邮件: public class User { public string name { get; set; } public string email { get; set; } } 在XAML方面,我绑定ListItem和ItemTemplate中的文本块,如下所示: <ListBox Name="Users" ItemsSource="{Binding}"> <TextBlock Text="{Binding Name}" Name="name" /> <TextBlock Text="{Binding Email}" Name="email" /> 在调试过程中,我可以看到用户列表框中填充了正确的项目,但是在退出方法后,应用程序崩溃了,我直接进入App.xaml.cs方法Application_UnhandledException.错误详细信息如下: e.ExceptionObject.InnerException {"0x8000ffff"} _data: null _HResult: -2146233088 _innerException: null _message: "0x8000ffff" _methodDescs: {System.IntPtr[14]} _optionalData: null Data: {System.Collections.ListDictionaryInternal} HResult: -2146233088 InnerException: Could not evaluate expression Message: "0x8000ffff" StackTrace: " at MS.Internal.XcpImports.CheckHResult(UInt32 hr)rn at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element,Size availableSize)rn at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)rn at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget,Single inWidth,Single inHeight,Single& outWidth,Single& outHeight)rn at MS.Internal.XcpImports.MeasureNative(IntPtr element,Single inHeight)rn at MS.Internal.XcpImports.UIElement_Measure(UIElement element,Size availableSize)rn at System.Windows.UIElement.Measure(Size availableSize)rn at System.Windows.Controls.VirtualizingStackPanel.MeasureChild(UIElement child,Size layoutSlotSize)rn at System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint)rn at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget,Single& outHeight)rn at MS.Internal.XcpImpor ts.MeasureOverrideNative(IntPtr element,Single& outHeight)rn at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element,Single& outHeight)rn" 我无法弄清楚这一点,并且非常感谢任何指导,或者对这类问题采取更好的方法.有一篇文章确实提到SilverLight不再支持ListDictionaryInternal,所以我不确定这是否可能是问题,因为错误详细信息指向ListDictionaryInternal. 解决方法
想听到奇怪的事情.我有这个问题,并在XAML中删除了一个style =“{StaticResource ….}并修复了它.有人可以解释为什么吗?我之后添加了一个本地StaticResource,它也有效.
如果您在ListBox项目中的任何位置都没有设置样式,那么此解决方案将无济于事. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Windows调试器路线图
- ms-access – 在Microsoft Access 2010中创建关系时“表上的
- windows – 您是否为开发生产服务器使用不同的壁纸或背景颜
- 将目录添加到Windows Path变量是否会影响性能?
- 由于私钥过滤,signtool无法在Windows 10上找到证书
- wcf – Windows 8上带有Microsoft帐户的Azure ACS 2.0
- windows-7 – 在OpenFiler上使用iSCSI LUN的VMotion
- Win10.更新
- active-directory – 内置的“提供远程协助”因权限无法正常
- “以我的Windows桌面扩展到这个显示器”以编程方式
推荐文章
站长推荐
热点阅读