Get focused MenuItem in submenu WPF

前端 未结 1 710
醉酒成梦
醉酒成梦 2021-01-22 11:31

I\'m writing an application with menu containing submenus. Also I have a StatusBar where I want to display information about focused MenuItem when user navigates in menu with ke

1条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-22 12:06

    Not sure if it applies to what you need exactly but I think it's what you need...

    It's always best to bind to view-model - and then you can expose that 'status' at some other place by simply binding to it...

    In case of IsFocused (If you're talking about the standard WPF menu items) there is a slight problem binding to it, as it's a read-only so binding fails with something like
    http://meleak.wordpress.com/2011/08/28/onewaytosource-binding-for-readonly-dependency-property/
    (that's also a good example of this solution, similar just for ActiveWidth/Height)