テンプレート ファイルに contextmenuitem とハンドラーと共に contextmenu を追加しようとしています。前者は問題ありませんが、VS ではテンプレート ファイルのメニュー項目にイベント ハンドラを追加できません。
<ControlTemplate TargetType="{x:Type local:CalendarDayView}">
<ControlTemplate.Resources>
<ContextMenu x:Key="dayEntryContextMenu">
<MenuItem Header="Remove entry" Click="removeEntryBtn"/>
</ContextMenu>
</ControlTemplate.Resources>
<Border BorderBrush="Gray" BorderThickness="1" Width="100" Height="100">
<Grid Name="contentGrid">
<ListBox Name="entriesListBox" Background="LightYellow" ContextMenu="{StaticResource dayEntryContextMenu}">
<ListBoxItem>Test entry #1</ListBoxItem>
<ListBoxItem>Test entry #2</ListBoxItem>
<ListBoxItem>Test entry #3</ListBoxItem>
</ListBox>
<!-- Date display below -->
<TextBlock Name="dateTextBlock" Text="31-Nov" FontFamily="Segoe UI Light" FontSize="18" VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
</Grid>
</Border>
</ControlTemplate>
エラー 1 'ResourceDictionary' root element requires ax:Class attribute to support event handlers in the XAML file. Click イベントのイベント ハンドラーを削除するか、ルート要素に ax:Class 属性を追加します。行 37 位置 61。
これを機能させる方法はありますか?