private static void OnButtonImageChanged(DependencyObject depobj, DependencyPropertyChangedEventArgs evargs) { SelectionButton tb = depobj as SelectionButton; tb.BtnImage.Source = evargs.NewValue as ImageSource; }
/// <summary> /// Constructor. /// </summary> /// <param name="Title">Window title</param> /// <param name="Message">Dialog message</param> /// <param name="AdditionalInfo">Additional information</param> /// <param name="AdditionalPanel">Additional panel for extended options (such as checkboxes and radiobuttons)</param> /// <param name="SelectionAction">Action to be executed upon option-button selection (it will receive the selected option TechName)</param> /// <param name="DefaultOption">TechName for the option to be marked as default</param> /// <param name="Options">Collection of recognizable-elements to be shown as options (each must have a different Code)</param> public DialogOptionsWindow(string Title, string Message, string AdditionalInfo, Panel AdditionalPanel, Action <string> SelectionAction, string DefaultOption, params IRecognizableElement[] Options) : this() { this.Title = ""; // This is OK. Must be established in the Loaded event when the template will be already applied. this.MessageText.Text = Message; this.AdditionalInfoText.Text = AdditionalInfo; SelectionButton FocusableButton = null; var RefWindow = this; Action <string> ExtendedSelectionAction = (techname) => { SelectionAction(techname); RefWindow.Close(); }; if (Options != null && Options.Any()) { if (DefaultOption.IsAbsent()) { DefaultOption = Options.First().TechName; } foreach (var Option in Options) { var NewButton = new SelectionButton(Option, ExtendedSelectionAction); if (Option.TechName == DefaultOption) { NewButton.IsDefault = true; FocusableButton = NewButton; } this.OptionsPanel.Children.Add(NewButton); } if (FocusableButton == null) { FocusableButton = this.OptionsPanel.Children[0] as SelectionButton; } } if (AdditionalPanel != null) { this.ContentPanel.Children.Add(AdditionalPanel); } var TargetWindow = this; TargetWindow.Loaded += ((sender, args) => { var BtnRestoreOrMaximize = Display.GetTemplateChild <Button>(TargetWindow, "BtnRestoreOrMaximize", true); BtnRestoreOrMaximize.Visibility = Visibility.Collapsed; TargetWindow.Title = Title; if (FocusableButton != null) { FocusableButton.Focus(); } }); }
private static void OnButtonCodeChanged(DependencyObject depobj, DependencyPropertyChangedEventArgs evargs) { SelectionButton tb = depobj as SelectionButton; tb.Tag = evargs.NewValue as string; }