public ToolBarItemGroup AddToolButton(ToolBarItemGroupModel model) { custom.Orientation = Orientation.Horizontal; ToolBarItemGroup item = new ToolBarItemGroup() { Model = model }; item.Model = model; custom.Margin = new Thickness(5, 0, 0, 0); custom.Children.Add(item); Rectangle _regtoolbaritem = new Rectangle(); _regtoolbaritem.Height = 18; _regtoolbaritem.Width = 1; _regtoolbaritem.Fill = new SolidColorBrush(Color.FromArgb(255, 154, 154, 153)); custom.Children.Add(_regtoolbaritem); _regtoolbaritem.Margin = new Thickness(67, 3, 0, 3); return item; }
public static void OnModelPropertyChanged(DependencyObject objects, DependencyPropertyChangedEventArgs args) { if (args.NewValue != null) { ToolBarItemGroup bases = objects as ToolBarItemGroup; ToolBarItemGroupModel model = args.NewValue as ToolBarItemGroupModel; bases.titel.DataContext = model; if (model.Items.Count > 0) { bases.more.Visibility = Visibility.Visible; } else { bases.more.Visibility = Visibility.Collapsed; } } }
public ToolBarItemGroup AddToolButton(ToolBarItemGroupModel model) { custom.Orientation = Orientation.Horizontal; ToolBarItemGroup item = new ToolBarItemGroup() { Model = model }; item.Model = model; custom.Margin = new Thickness(5, 0, 0, 0); custom.Children.Add(item); Rectangle _regtoolbaritem = new Rectangle(); _regtoolbaritem.Height = 18; _regtoolbaritem.Width = 1; _regtoolbaritem.Fill = new SolidColorBrush(Color.FromArgb(255, 154, 154, 153)); custom.Children.Add(_regtoolbaritem); _regtoolbaritem.Margin = new Thickness(67, 3, 0, 3); return(item); }
void more_Click(object sender, RoutedEventArgs e) { if (itemPop.IsOpen) { itemPop.IsOpen = false; } else { if (_createChild) { itemPop.IsOpen = true; } else { #region 初始化子菜单 _createChild = true; Canvas parent = new Canvas(); parent.MouseLeftButtonDown += (o, args) => { if (itemPop.IsOpen) { itemPop.IsOpen = false; } }; StackPanel itemPanel = new StackPanel() { Orientation = Orientation.Vertical, Background = new SolidColorBrush(Colors.Gray), Margin = new Thickness(3, 0, 0, 0) }; itemPanel.Effect = new DropShadowEffect(); ToolBarItemGroupModel model = new ToolBarItemGroupModel() { DataContext=this.Model.DataContext, IocPath=this.Model.IocPath, IsActivate=this.Model.IsActivate, Titel=this.Model.Titel, URL=this.Model.URL }; ToolBarItemGroup firstChild = new ToolBarItemGroup() { Model = model, Margin = new Thickness(1), Height = 26, Width = 75 }; firstChild.Click += (o, args) => { if (Click != null) Click(o, args); }; itemPanel.Children.Add(firstChild); foreach (var item in Model.Items) { ToolBarItemGroup child = new ToolBarItemGroup() { Model = item, Margin = new Thickness(1), Height = 26, Width = 75 }; child.Click += (o, args) => { if (Click != null) Click(o, args); }; itemPanel.Children.Add(child); } itemPanel.Height = (Model.Items.Count + 1) * 28; parent.Children.Add(itemPanel); itemPop.Child = parent; double top = Canvas.GetTop(Item) + Item.ActualHeight; Canvas.SetTop(itemPop, top); Root.Children.Add(itemPop); itemPop.IsOpen = true; #endregion } } }
void more_Click(object sender, RoutedEventArgs e) { if (itemPop.IsOpen) { itemPop.IsOpen = false; } else { if (_createChild) { itemPop.IsOpen = true; } else { #region 初始化子菜单 _createChild = true; Canvas parent = new Canvas(); parent.MouseLeftButtonDown += (o, args) => { if (itemPop.IsOpen) { itemPop.IsOpen = false; } }; StackPanel itemPanel = new StackPanel() { Orientation = Orientation.Vertical, Background = new SolidColorBrush(Colors.Gray), Margin = new Thickness(3, 0, 0, 0) }; itemPanel.Effect = new DropShadowEffect(); ToolBarItemGroupModel model = new ToolBarItemGroupModel() { DataContext = this.Model.DataContext, IocPath = this.Model.IocPath, IsActivate = this.Model.IsActivate, Titel = this.Model.Titel, URL = this.Model.URL }; ToolBarItemGroup firstChild = new ToolBarItemGroup() { Model = model, Margin = new Thickness(1), Height = 26, Width = 75 }; firstChild.Click += (o, args) => { if (Click != null) { Click(o, args); } }; itemPanel.Children.Add(firstChild); foreach (var item in Model.Items) { ToolBarItemGroup child = new ToolBarItemGroup() { Model = item, Margin = new Thickness(1), Height = 26, Width = 75 }; child.Click += (o, args) => { if (Click != null) { Click(o, args); } }; itemPanel.Children.Add(child); } itemPanel.Height = (Model.Items.Count + 1) * 28; parent.Children.Add(itemPanel); itemPop.Child = parent; double top = Canvas.GetTop(Item) + Item.ActualHeight; Canvas.SetTop(itemPop, top); Root.Children.Add(itemPop); itemPop.IsOpen = true; #endregion } } }