private void AddProxyMenuUI(Menu currentMenu) { _ic .FindAllElementsByType<Grid>() .ObserveOnDispatcher() .Subscribe(c => { var text = c.FindElement<TextBlock>(); var i = _ic.Items.IndexOf(text.Text); //skip the current menu var m = CorrectChildren.ElementAt(i) as Menu; if (m != null && m.Equals(currentMenu)) return; var menuParentPosition = c.GetPosition(Application.Current.RootVisual); var adjustedPosition = new Point(menuParentPosition.X + 7, menuParentPosition.Y); var ng = new Grid { Background = new SolidColorBrush(Colors.Transparent), Width = text.ActualWidth, Height = 22, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, Tag = "proxy" }; ng.MouseEnter += (_, __) => { if (_hoverShow) { ShowMenu(c, CorrectChildren.ElementAt(i) as Menu, true); } else { ExtendedVisualStateManager.GoToElementState(c, "Hover", true); } }; ng.MouseLeave += (_, __) => ExtendedVisualStateManager.GoToElementState(c, "Normal", true); ng.MouseLeftButtonDown += (_, args) => { ShowMenu(c, CorrectChildren.ElementAt(i) as Menu, true); args.Handled = true; }; MenuLayer.Children.Add(ng); ng.AbsoluteTransformPositionTo(adjustedPosition, Application.Current.RootVisual); }); }