Visual Studio 的 C# 编译器提示一个没有基础的错误:“'ItemSelection' 没有重载与 MainPage.xaml 中的委托 'OnItemSelected' 匹配”(或者我是盲人,看不到错误)尽管有错误出现的事实,但现在没有(奇怪的是)。感谢您的帮助。
//MainPage.xaml
<ListBox.ItemTemplate>
<DataTemplate>
<local:WordBlock Word="{Binding}" OnSlideOccured="OnSlide" OnItemSelection="ItemSelection"/>
</DataTemplate>
</ListBox.ItemTemplate>
//MainPage.xaml.cs
private void ItemSelection(string word)
{
ToSearch = word;
(Panorama.Items[0] as PanoramaItem).Visibility = Visibility.Collapsed;
Panorama.SetValue(Panorama.SelectedItemProperty, Panorama.Items[0]);
Panorama.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
(Panorama.Items[0] as PanoramaItem).Visibility = Visibility.Visible;
}
//WordBlock.xaml.cs
public delegate void OnItemSelected(string word);
public event OnItemSelected OnItemSelection;