From: Adam Clauss on 17 Nov 2009 19:08 I've recently started looking into WPF. What is the expected scope of a context menu? For example, I have a web browser application. To the main "Page" I added a context menu (along with various other children embedded within a Grid - buttons, etc). If I then launch the application and right click on an empty part of the page, I do NOT get a context menu. If I right click on any of the children, say a Button, the context menu appears. What I EXPECTED to happen was the context menu to appear when I right clicked on an empty part of the page. I did NOT expect it to "cascade" down to children. I only very briefly tried this and am about to go home for the day. I'll poke into it in more depth tomorrow, just wanted to see if this immediately jumped out at anyone as obvious. Thanks, Adam
From: Adam Clauss on 18 Nov 2009 10:28 Adam Clauss wrote: > I've recently started looking into WPF. What is the expected scope of > a context menu? For example, I have a web browser application. To > the main "Page" I added a context menu (along with various other > children embedded within a Grid - buttons, etc). > If I then launch the application and right click on an empty part of > the page, I do NOT get a context menu. If I right click on any of the > children, say a Button, the context menu appears. > > What I EXPECTED to happen was the context menu to appear when I right > clicked on an empty part of the page. I did NOT expect it to > "cascade" down to children. I only very briefly tried this and am > about to go home for the day. I'll poke into it in more depth > tomorrow, just > wanted to see if this immediately jumped out at anyone as obvious. > > Thanks, > Adam OK, it appears I was not going crazy yesterday, but the context menu is working exactly opposite of how I would expect. I created a basic simple WPF application (not a browser application as in my attempt yesterday). The XAML looks is simply: <Window x:Class="WpfContextMenuTest.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Grid> <Grid.ContextMenu> <ContextMenu> <MenuItem Header="Test Item" /> </ContextMenu> </Grid.ContextMenu> <Button Height="23" HorizontalAlignment="Left" Margin="44,42,0,0" Name="button1" VerticalAlignment="Top" Width="75">Button</Button> </Grid> </Window> When I run that, if I right click on the form itself, I get no context menu. If I right click on the button, I get my "Test Item" context menu. I want the inverse of that. The button shouldn't have a context menu, and when I click on the "background", that should popup the menu. What am I doing wrong here?? Thanks, Adam
|
Pages: 1 Prev: Enterprise design: Accessing global 'config' data Next: Event Handler |