コード例 #1
0
            void AddNaviBar(object sender, RoutedEventArgs e)
            {
                _View.VisualElement.Loaded -= AddNaviBar;

                var view    = sender as FrameworkElement;
                var naviBar = view
                              ?.GetParent <Border>(b => b.Name == "PART_ContentPanel")
                              ?.GetFirstVisualChild <Border>(b => b.Name == "DropDownBarMargin");

                if (naviBar == null)
                {
                    var naviBarHolder = view.GetParent <Panel>(b => b.GetType().Name == "WpfMultiViewHost");
                    if (naviBarHolder != null)
                    {
                        var b = new MarkdownBar(_View, _TextSearch);
                        DockPanel.SetDock(b, Dock.Top);
                        if (naviBarHolder.Children.Count == 1)
                        {
                            naviBarHolder.Children.Insert(0, b);
                        }
                        else
                        {
                            var c = naviBarHolder.Children[0] as ContentControl;
                            if (c != null && c.Content == null)
                            {
                                c.Content = b;
                            }
                        }
                    }
                    return;
                }
                var dropDown1 = naviBar.GetFirstVisualChild <ComboBox>(c => c.Name == "DropDown1");
                var dropDown2 = naviBar.GetFirstVisualChild <ComboBox>(c => c.Name == "DropDown2");

                if (dropDown1 == null || dropDown2 == null)
                {
                    return;
                }
                var container = dropDown1.GetParent <Grid>();

                if (container == null)
                {
                    return;
                }
                var bar = new CSharpBar(_View)
                {
                    MinWidth = 200
                };

                bar.SetCurrentValue(Grid.ColumnProperty, 2);
                bar.SetCurrentValue(Grid.ColumnSpanProperty, 3);
                container.Children.Add(bar);
                dropDown1.Visibility = Visibility.Hidden;
                dropDown2.Visibility = Visibility.Hidden;
                naviBar.Unloaded    += ResurrectNaviBar_OnUnloaded;
            }
コード例 #2
0
ファイル: NaviBarFactory.cs プロジェクト: Anil1111/Codist
            void FindNaviBar(object sender, RoutedEventArgs e)
            {
                var view    = sender as FrameworkElement;
                var naviBar = view
                              ?.GetParent <Border>(b => b.Name == "PART_ContentPanel")
                              ?.GetFirstVisualChild <Border>(b => b.Name == "DropDownBarMargin");

                if (naviBar == null)
                {
                    goto EXIT;
                }
                var dropDown1 = naviBar.GetFirstVisualChild <ComboBox>(c => c.Name == "DropDown1");
                var dropDown2 = naviBar.GetFirstVisualChild <ComboBox>(c => c.Name == "DropDown2");

                if (dropDown1 == null || dropDown2 == null)
                {
                    goto EXIT;
                }
                var container = dropDown1.GetParent <Grid>();

                if (container == null)
                {
                    goto EXIT;
                }
                var bar = new CSharpBar(_View)
                {
                    MinWidth = 200
                };

                bar.SetCurrentValue(Grid.ColumnProperty, 2);
                bar.SetCurrentValue(Grid.ColumnSpanProperty, 3);
                container.Children.Add(bar);
                dropDown1.Visibility = Visibility.Hidden;
                dropDown2.Visibility = Visibility.Hidden;
EXIT:
                UnloadEvents();
            }