public ToolBarCheckBox(Codon codon, object caller, IReadOnlyCollection <ICondition> conditions) { ToolTipService.SetShowOnDisabled(this, true); this.codon = codon; this.caller = caller; this.conditions = conditions; Command = CommandWrapper.CreateCommand(codon, conditions); CommandParameter = caller; var cmd = CommandWrapper.Unwrap(Command) as ICheckableMenuCommand; if (cmd != null) { isCheckedBinding = SetBinding(IsCheckedProperty, new Binding("IsChecked") { Source = cmd, Mode = BindingMode.OneWay }); } Content = ToolBarService.CreateToolBarItemContent(codon); if (codon.Properties.Contains("name")) { Name = codon.Properties["name"]; } UpdateText(); SetResourceReference(FrameworkElement.StyleProperty, ToolBar.CheckBoxStyleKey); }
public MenuCheckBox(UIElement inputBindingOwner, Codon codon, object caller, IReadOnlyCollection <ICondition> conditions) : base(codon, caller, conditions) { Command = CommandWrapper.CreateCommand(codon, conditions); CommandParameter = caller; cmd = CommandWrapper.Unwrap(Command) as ICheckableMenuCommand; if (cmd != null) { isCheckedChangedHandler = cmd_IsCheckedChanged; cmd.IsCheckedChanged += isCheckedChangedHandler; IsChecked = cmd.IsChecked(caller); } if (!string.IsNullOrEmpty(codon.Properties["shortcut"])) { KeyGesture kg = MenuService.ParseShortcut(codon.Properties["shortcut"]); MenuCommand.AddGestureToInputBindingOwner(inputBindingOwner, kg, Command, null); InputGestureText = MenuService.GetDisplayStringForShortcut(kg); } }