Context menu event handling error - CS1061

Posted by MrTemp on Stack Overflow See other posts from Stack Overflow or by MrTemp
Published on 2010-05-15T22:17:17Z Indexed on 2010/05/15 22:20 UTC
Read the original article Hit count: 487

Filed under:
|
|
|

I am still new to c# and wpf This program is a clock with different view and I would like to use the context menu to change between view, but the error says that there is no definition or extension method for the events. Right now I have the event I'm working on popping up a MessageBox just so I know it has run, but I cannot get it to compile.

   public partial class MainWindow : NavigationWindow
{
    public MainWindow()
    {
        //InitializeComponent();
    }

    public void AnalogMenu_Click(object sender, RoutedEventArgs e)
    {
        /*AnalogClock analog = new AnalogClock();
        this.NavigationService.Navigate(analog);*/
    }

    public void DigitalMenu_Click(object sender, RoutedEventArgs e)
    {
        MessageBox.Show("Digital Clicked");
        /*DigitalClock digital = new DigitalClock();
        this.NavigationService.Navigate(digital);*/
    }

    public void BinaryMenu_Click(object sender, RoutedEventArgs e)
    {
        /*BinaryClock binary = new BinaryClock();
        this.NavigationService.Navigate(binary);*/
    }
}

and the xaml call if you want it

    <NavigationWindow.ContextMenu>
    <ContextMenu Name="ClockMenu" >
        <MenuItem Name="ToAnalog" Header="To Analog" ToolTip="Changes to an analog clock"/>
        <MenuItem Name="ToDigital" Header="To Digital" ToolTip="Changes to a digital clock" Click="DigitalMenu_Click" />
        <MenuItem Name="ToBinary" Header="To Binary" ToolTip="Changes to a binary clock"/>
    </ContextMenu>
</NavigationWindow.ContextMenu>

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf