Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - WPF MenuItem hiding

 
 
Old 09-28-2009   #1 (permalink)
Dmitry Nogin


 
 

WPF MenuItem hiding

Hi,

I would like to hide selected MenuItem on <Delete> key press without closing the menu.

My markup is:


<Menu>

<MenuItem Header="Menu">

<MenuItem Header="First" KeyDown="MenuItem_KeyDown"/>

<MenuItem Header="Second" KeyDown="MenuItem_KeyDown"/>

<MenuItem Header="Third" KeyDown="MenuItem_KeyDown"/>

</MenuItem>

</Menu>

where event handler is:

private void MenuItem_KeyDown(object sender, KeyEventArgs e)

{

if (e.Key == Key.Delete)

{

MenuItem mi = (MenuItem)sender;

mi.Visibility = Visibility.Collapsed;

}

}



Unfortunately, I can not hide currently highlighted MenuItem without the whole menu collapse.



The question is how to bypass this misbehavior? How to change menu selection before hiding?





P.S. Which newsgroup should use I to ask WPF related questions?





Thanks,

-- Dmitry




My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
WPF MenuItem hiding .NET General
Win Med is hiding from me!?! Sound & Audio


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46