C# 更新ViewModel中的属性后未实现异常0x80004001

C# 更新ViewModel中的属性后未实现异常0x80004001,c#,silverlight,silverlight-3.0,windows-phone-7,viewmodel,C#,Silverlight,Silverlight 3.0,Windows Phone 7,Viewmodel,上下文是用于Windows Phone 7的Silverlight应用程序。我正在用模拟器调试 我有一个MainPage.xaml,在其数据上下文中附加了一个ViewModel。 当页面导航到时,将在ViewModel中调用一个方法来调用API并显示信息 我有一个方法,可以创建一个字典,用数据填充它,并在实现PropertyChanged事件的属性中设置它 调用此方法后,调试器会在App.Application\u UnhandledException中使用NotImplementedExcep

上下文是用于Windows Phone 7的Silverlight应用程序。我正在用模拟器调试

我有一个
MainPage.xaml
,在其数据上下文中附加了一个ViewModel。
当页面导航到时,将在ViewModel中调用一个方法来调用API并显示信息

我有一个方法,可以创建一个
字典
,用数据填充它,并在实现
PropertyChanged
事件的属性中设置它

调用此方法后,调试器会在App.Application\u UnhandledException中使用NotImplementedException中断

如果使用调试器跳过对此方法的调用,则不会引发异常

奇怪的是,异常是在调用方法后引发的,而不是在内部!该异常不包含InnerException。HResult为-2147467263,消息中包含“0x80004001”。以下是StackTrace:

at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
at MS.Internal.XcpImports.MeasureNative(IntPtr element, Single inWidth, Single inHeight)
at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at Microsoft.Phone.Controls.Primitives.PanoramaPanel.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
at MS.Internal.XcpImports.MeasureOverrideNative(IntPtr element, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
at MS.Internal.XcpImports.MeasureOverrideNative(IntPtr element, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
at Microsoft.Phone.Controls.Panorama.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
at MS.Internal.XcpImports.MeasureOverrideNative(IntPtr element, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
at MS.Internal.XcpImports.MeasureOverrideNative(IntPtr element, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
at Microsoft.Phone.Controls.PhoneApplicationFrame.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
调试输出包含:

A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll (x10)
A first chance exception of type 'System.NotImplementedException' occurred in System.Windows.dll (x6)

哦。我通过检查XAML端的数据绑定发现了一个用户错误。这是我的XAML:

<TextBlock Grid.Column="0" Text="{Binding Value}"
           Style="PhoneTextLargeStyle" />
<TextBlock Grid.Column="1" Text="{Binding Key}"
           Style="PhoneTextLargeStyle" />

我忘了写它是一个静态资源:

<TextBlock Grid.Column="0" Text="{Binding Value}"
           Style="{StaticResource PhoneTextLargeStyle}" />
<TextBlock Grid.Column="1" Text="{Binding Key}"
           Style="{StaticResource PhoneTextLargeStyle}" />

让我们希望这个愚蠢的问题/自动回答能帮助某人:)