【发布时间】:2012-04-18 05:40:38
【问题描述】:
在 windows phone 7.1 项目中:
我的资源字典如下所示:
<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>
ManipulationStarted() 和 ManipulationCompleted() 函数位于 MainPage.xaml.cs 中,通过 MainPage.xaml 使用以下代码引用 DataTemplate:
<toolkit:LongListSelector x:Name="ListSelector"
ItemTemplate="{StaticResource ItemsTemplate}"
ItemsSource="{Binding Items}">
</toolkit:LongListSelector>
当我尝试在列表中添加项目时出现异常。
如果我将 DataTemplate 放在 MainPage.xaml 中,一切正常。
我知道问题出在函数引用上,但我想首先知道为什么无法通过资源字典找到函数,以及是否有适当的方法来执行此操作或通过任何技巧来克服此问题.
【问题讨论】:
-
App.Application_UnhandledException(object sender, System.Windows.ApplicationUnhandledExceptionEventArgs e) Line 150 + 0x5 bytes C# {"Unspecified error"}
标签: c# windows-phone-7 xaml resourcedictionary