public override void OnApplyTemplate() { if (SymbolSelector != null) SymbolSelector.SymbolSelected -= SymbolSelector_SymbolSelected; if (SymbolDropDownButton != null) SymbolDropDownButton.IsContentPopupOpen = false; base.OnApplyTemplate(); SymbolSelector = GetTemplateChild("SymbolSelector") as SymbolSelector; if (SymbolSelector != null) SymbolSelector.SymbolSelected += SymbolSelector_SymbolSelected; SymbolDisplay = GetTemplateChild("SymbolDisplay") as SymbolDisplay; SymbolDropDownButton = GetTemplateChild("SymbolDropDownButton") as DropDownButton; if (InitCompleted != null) InitCompleted(this, EventArgs.Empty); }
public ButtonBase AddToolGroupButton(ButtonDisplayInfo buttonDisplayInfo, ICommand buttonCommand, IList<FrameworkElement> parentContainer, int position = -1) { string menuButtonStyle = isPopupToolPanel ? "PopupMenuButtonStyle" : "MenuButtonStyle"; ButtonBase btn = createButton(buttonDisplayInfo, buttonCommand, ToolPanelLayoutStyleHelper.Instance.GetStyle(menuButtonStyle), false); btn.Click += groupNodeButton_Click; StackPanel stackPanel = new StackPanel(); DropDownButton dropDownButton = new DropDownButton() { Content = btn, PopupContent = stackPanel, PopupContentContainerStyle = ToolPanelLayoutStyleHelper.Instance.GetStyle(PopupStyleName.PopupContentControl.ToString()), PopupLeaderStyle = ToolPanelLayoutStyleHelper.Instance.GetStyle(PopupStyleName.PopupLeader.ToString()), }; if (position < 0 || position >= parentContainer.Count) { parentContainer.Add(dropDownButton); if (buttonCommand != null) toolItems.Add(buttonCommand); } else { parentContainer.Insert(position, dropDownButton); if (buttonCommand != null) toolItems.Insert(position, buttonCommand); } return dropDownButton; }
public override void OnApplyTemplate() { base.OnApplyTemplate(); initializeColorBrush(); initializeThemeColors(); if (ColorPalette != null) ColorPalette.ColorPicked -= ColorPalette_ColorPicked; ColorPalette = GetTemplateChild("ColorPalette") as ColorPalette; if (ColorPalette != null) { ColorPalette.ColorPicked += ColorPalette_ColorPicked; if (ColorBrush != null) ColorPalette.SelectedColorBrush = ColorBrush; } if (DropDownButton != null) { DropDownButton.Opening -= DropDownButton_Opening; DropDownButton.PopupContent = null; } DropDownButton = GetTemplateChild("DropDownButton") as DropDownButton; if (DropDownButton != null) { DropDownButton.Opening += DropDownButton_Opening; } if (InitCompleted != null) InitCompleted(this, EventArgs.Empty); }
/// <summary> /// IsContentPopupOpenProperty property changed handler. /// </summary> /// <param name="d">DropDownButton that changed its IsContentPopupOpen.</param> /// <param name="e">Event arguments.</param> private static void OnIsContentPopupOpenPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DropDownButton source = d as DropDownButton; source.OnIsContentPopupOpenPropertyChanged(); }