How to get not null AdornerLayer for MenuItem before expanding the menu

  • Thread starter Thread starter tomas666
  • Start date Start date
T

tomas666

Guest
Following code snippet gives me null adornerLayer

Menu menu = (Menu)this.FindName("Menu");
MenuItem menuItem = (MenuItem) menu.Items.GetItemAt(0);


MenuItem subMenuItem = (MenuItem) menuItem.Items.GetItemAt(1);

var layer = AdornerLayer.GetAdornerLayer(subMenuItem);
layer.Add(new SimpleCircleAdorner(subMenuItem));


In case that I'll add line:

menuItem.IsSubmenuOpen = true

Menu is expanded programatically and the adorner layer is not null.
Is there a possibility to get not-null adorner for not expanded menu? (for first time)
Edit1: Ok, it seems that visual tree is not created before menu-open. I'm still not sure how to trigger creation of visual tree programmatically.


Continue reading...
 
Back
Top