I'm trying to add a contextmenu along with a contextmenuitem and a handler in a template file. The former things are fine but VS won't let me add a eventhandler to the menuitem in the template file, it looks like so
<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>
The error I'm getting is Error 1 'ResourceDictionary' root element requires a x:Class attribute to support event handlers in the XAML file. Either remove the event handler for the Click event, or add a x:Class attribute to the root element. Line 37 Position 61.
Is there any way to make this work?