C# 资源字典在调用位于MainPage中的方法时引发异常
在windows phone 7.1项目中: 我的资源字典如下所示:C# 资源字典在调用位于MainPage中的方法时引发异常,c#,windows-phone-7,xaml,resourcedictionary,C#,Windows Phone 7,Xaml,Resourcedictionary,在windows phone 7.1项目中: 我的资源字典如下所示: <DataTemplate x:Name="ItemsTemplate"> ... <StackPanel VerticalAlignment="Top" ManipulationStarted="ManipulationStarted" Manipulat
<DataTemplate x:Name="ItemsTemplate">
...
<StackPanel VerticalAlignment="Top"
ManipulationStarted="ManipulationStarted"
ManipulationCompleted="ManipulationCompleted">
<TextBlock Text="{Binding ItemDescription}" FontSize="32" Foreground="#FF3B3B3B" Margin="5,0,0,0" FontWeight="Bold" />
<TextBlock Text="{Binding List.ListName}" FontSize="20" Foreground="DarkMagenta" Margin="5,0,0,0" FontWeight="Bold"/>
</StackPanel>
</StackPanel>
</DataTemplate>
...
OperationStarted()和OperationCompleted()函数位于MainPage.xaml.cs中,数据模板通过MainPage.xaml引用,代码如下:
<toolkit:LongListSelector x:Name="ListSelector"
ItemTemplate="{StaticResource ItemsTemplate}"
ItemsSource="{Binding Items}">
</toolkit:LongListSelector>
当我尝试在列表中添加项目时,我得到一个异常
如果我将DataTemplate放在MainPage.xaml中,一切正常
我知道问题出在函数引用上,但我想首先了解为什么无法通过资源字典找到函数,以及是否有正确的方法来完成此操作或通过任何技巧来克服此问题。您是否应该使用
x:Key
而不是x:Name
DataTemplate
?问题在于事件接线。在应用程序级别没有相应的事件处理程序,但我猜在页面级别有。App.Application\u未处理的异常(对象发送方,System.Windows.applicationUnhandledExceptionEventTargets e)行150+0x5字节C 35;{“未指定错误”}没什么区别。我在想办法让它发挥作用的时候改变了它!没有发现,我想你知道了!但是,资源词典不是像图书馆那样链接在“页面”上吗?我的意思是像我们使用#includes(c)或on(c#)一样??有解决办法吗?