locked
Where is Context Menu? RRS feed

  • Question

  • Hi all,

    I could not find a ContextMenu control anywhere in the asset library so I went ahead and created one via xaml.  Now that I've created one I cannot seem to find it in the Objects and Timeline.

    Is this a bug or am I doing something wrong?

    Thanks,
    -ja

    Tuesday, February 24, 2009 6:49 PM

All replies

  • But there is a ContextMenu-Class in WPF

    Have a look at:

    <TextBox>

    <TextBox.ContextMenu>

    <MenuItem ... >

    ...

    </MenuItem>

    </TextBox.ContextMenu>

    </TextBox>

    Wednesday, February 25, 2009 12:58 PM
  • Yes I did see that, thank you very much.  One thing that I noticed about it is that it cannot be declared directly.  If you declare like this -
    <Grid> 
        <ContextMenu> 
            <MenuItem x:Name="cmiShowByUsers" Click="cmiShowByUsers_Click" Header="Show by Users" /> 
            <MenuItem x:Name="cmiShowByTests" Click="cmiShowByTests_Click" Header="Show by Tests" /> 
        </ContextMenu> 
    </Grid> 
     

    You get this error -

    System.Windows.Markup.XamlParseException occurred
      Message="'ContextMenu' object cannot be added to 'Grid'. 'ContextMenu' cannot have a logical or visual parent.  Error at object

    But this does work.
    <Grid Grid.Row="1">  
        <Grid.ContextMenu> 
            <ContextMenu> 
                <MenuItem x:Name="cmiShowByUsers" Click="cmiShowByUsers_Click" Header="Show by Users" /> 
                <MenuItem x:Name="cmiShowByTests" Click="cmiShowByTests_Click" Header="Show by Tests" /> 
            </ContextMenu> 
        </Grid.ContextMenu> 
    </Grid> 
     

    I don't get it, can somebody help me out here?

    Wednesday, February 25, 2009 3:06 PM
  • Hi,

    Add Textbox or Button on the WPF Form

    and go to properties window/panel then in the search box type context you will find it.

    context menu will be associated with  control / window and it will be available in properties of that object.

    I hope this will help you :)



    Prasad - www.beautifulmind.blog.co.in
    • Proposed as answer by prasad22 Wednesday, February 25, 2009 6:22 PM
    Wednesday, February 25, 2009 6:22 PM