/// <summary> /// Sets the value of the attached <see cref="FontSizeProperty"/> on a control. /// </summary> /// <param name="control">The control.</param> /// <param name="value">The property value to set.</param> /// <returns>The font family.</returns> public static void SetFontSize(Control control, double value) { control.SetValue(FontSizeProperty, value); }
/// <summary> /// Sets the value of the IsTemplateFocusTargetProperty attached property on a control. /// </summary> /// <param name="control">The control.</param> /// <param name="value">The property value.</param> /// <remarks> /// When a control is navigated to using the keyboard, a focus adorner is shown - usually /// around the control itself. However if the TemplatedControl.IsTemplateFocusTarget /// attached property is set to true on an element in the control template, then the focus /// adorner will be shown around that control instead. /// </remarks> public static void SetIsTemplateFocusTarget(Control control, bool value) { control.SetValue(IsTemplateFocusTargetProperty, value); }
public static void SetIsControlSizeBound(Control element, bool Value) { element.SetValue(IsControlSizeBoundProperty, Value); }
public static void SetCommand(Control target, ICommand value) { target.SetValue(CommandProperty, value); }
public static void SetEventType(Control target, EventType value) { target.SetValue(EventTypeProperty, value); }
/// <summary> /// Sets the value of the ToolTip.Tip attached property. /// </summary> /// <param name="element">The control to get the property from.</param> /// <param name="value">The content to be displayed in the control's tooltip.</param> public static void SetTip(Control element, object value) { element.SetValue(TipProperty, value); }
public static void SetDataContext(Control control, object value) { control.SetValue(DataContextProperty, value); }
/// <summary> /// Sets the show delay. /// </summary> /// <param name="element">The element.</param> /// <param name="value">The value.</param> public static void SetShowDelay(Control element, int value) { element.SetValue(ShowDelayProperty, value); }
/// <summary> /// Sets the tip. /// </summary> /// <param name="element">The element.</param> /// <param name="value">The value.</param> public static void SetTip(Control element, object value) { element.SetValue(TipProperty, value); }
/// <summary> /// Sets the placement. /// </summary> /// <param name="element">The element.</param> /// <param name="value">The value.</param> public static void SetPlacement(Control element, PlacementMode value) { element.SetValue(PlacementProperty, value); }
/// <summary> /// Sets the react to parent. /// </summary> /// <param name="element">The element.</param> /// <param name="value">if set to <c>true</c> [value].</param> public static void SetReactToParent(Control element, bool value) { element.SetValue(ReactToParentProperty, value); }
/// <summary> /// Sets the is open. /// </summary> /// <param name="element">The element.</param> /// <param name="value">if set to <c>true</c> [value].</param> public static void SetIsOpen(Control element, bool value) { element.SetValue(IsOpenProperty, value); }
private static void SetFocusedElement(Control control, FrameworkElement value) { control.SetValue(FocusedElementProperty, value); }
public static void SetIsSystemFocusVisual(Control control, bool value) { control.SetValue(IsSystemFocusVisualProperty, value); }
/// <summary> /// Sets the value of the attached <see cref="FontWeightProperty"/> on a control. /// </summary> /// <param name="control">The control.</param> /// <param name="value">The property value to set.</param> /// <returns>The font family.</returns> public static void SetFontWeight(Control control, FontWeight value) { control.SetValue(FontWeightProperty, value); }
/// <summary> /// Sets the vertical offset. /// </summary> /// <param name="element">The element.</param> /// <param name="value">The value.</param> public static void SetVerticalOffset(Control element, double value) { element.SetValue(VerticalOffsetProperty, value); }
/// <summary> /// Sets the value of the attached <see cref="NameScopeProperty"/> on a visual. /// </summary> /// <param name="visual">The visual.</param> /// <param name="value">The value to set.</param> public static void SetNameScope(Control visual, INameScope value) { visual.SetValue(NameScopeProperty, value); }
// Standard Get and Set methods for an AttachedProperty public static void SetAskUserRequest(Control element, IResponsive <string, bool> value) { element.SetValue(AskUserRequestProperty, value); }
public static void SetHeight(Control control, double value) { control.SetValue(HeightProperty, value); }
public static void SetIsEnabled(Control o, bool value) { o.SetValue(IsEnabledProperty, value); }
public static void SetUsingTextContextMenu(Control textControl, bool value) { textControl.SetValue(UsingTextContextMenuProperty, value); }
public static void SetFocus(Control attached, ShortcutName value) { attached.SetValue(FocusProperty, value); }
public static void SetCommandParameter(Control target, object value) { target.SetValue(CommandParameterProperty, value); }
public void TestAttachedPropertiesValidate() { var control = new Control(); Assert.Throws <ArgumentException>(() => control.SetValue(_refTypeAttachedProperty, "bar")); }
public static void SetFocusOnFirstElement(Control control, bool value) { control.SetValue(FocusOnFirstElementProperty, value); }
public void TestAttachedPropertiesInvalidNull() { var control = new Control(); Assert.Throws <ArgumentNullException>(() => control.SetValue(_valueTypeAttachedProperty, null)); }
public static void SetFocusFirst(Control control, bool value) => control.SetValue(FocusFirstProperty, value);
public void TestAttachedPropertiesValidNull() { var control = new Control(); control.SetValue(_nullableAttachedProperty, null); }
/// <summary> /// Sets the value of the attached <see cref="FontFamilyProperty"/> on a control. /// </summary> /// <param name="control">The control.</param> /// <param name="value">The property value to set.</param> /// <returns>The font family.</returns> public static void SetFontFamily(Control control, string value) { control.SetValue(FontFamilyProperty, value); }
/// <summary> /// Sets the value of the attached <see cref="FontStyleProperty"/> on a control. /// </summary> /// <param name="control">The control.</param> /// <param name="value">The property value to set.</param> /// <returns>The font family.</returns> public static void SetFontStyle(Control control, FontStyle value) { control.SetValue(FontStyleProperty, value); }
public static void SetWidth(Control control, double value) { control.SetValue(WidthProperty, value); }
/// <summary> /// Sets the value of the attached <see cref="ForegroundProperty"/> on a control. /// </summary> /// <param name="control">The control.</param> /// <param name="value">The property value to set.</param> /// <returns>The font family.</returns> public static void SetForeground(Control control, Brush value) { control.SetValue(ForegroundProperty, value); }
//display filter settings in the UI private void DisplayCurrentFilterSettings() { //set the info label text var infoLabel = ((System.Windows.Controls.Label) this.FindName("FilterInfo")); infoLabel.Content = this.currentFilter?.Info ?? "no Filter Selected..."; var settingsGrid = ((System.Windows.Controls.Grid) this.FindName("SettingsGrid")); //clear all row and setting-elementss if there are some settingsGrid.RowDefinitions.Clear(); settingsGrid.Children.Clear(); int rowCount = 0; if (null != currentFilter && currentFilter.Settings.Count() > 0) { foreach (Setting setting in currentFilter.Settings) { //add a row for this setting settingsGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); //create label Label label = new Label(); label.Content = setting.Name; label.ToolTip = setting.Info; label.SetValue(Grid.ColumnProperty, 0); label.SetValue(Grid.RowProperty, rowCount); settingsGrid.Children.Add(label); Control newSettingControl = null; if (setting.GetType() == typeof(SettingInteger)) { label.Content = $"{setting.Name} : {((SettingInteger)setting).Value}"; Slider slider = new Slider(); slider.ToolTip = setting.Info; slider.Maximum = ((SettingInteger)setting).MaxValue; slider.Minimum = ((SettingInteger)setting).MinValue; slider.Value = ((SettingInteger)setting).Value; slider.TickPlacement = System.Windows.Controls.Primitives.TickPlacement.BottomRight; slider.AutoToolTipPlacement = System.Windows.Controls.Primitives.AutoToolTipPlacement.BottomRight; slider.ValueChanged += (object sender, RoutedPropertyChangedEventArgs <double> e) => { ((SettingInteger)setting).Value = (int)e.NewValue; label.Content = $"{setting.Name} : {((SettingInteger)setting).Value}"; return; }; newSettingControl = slider; } else if (setting.GetType() == typeof(SettingBoolean)) { CheckBox checkBox = new CheckBox(); checkBox.IsChecked = ((SettingBoolean)setting).Value; checkBox.Checked += (object sender, RoutedEventArgs e) => { ((SettingBoolean)setting).Value = true; }; checkBox.Unchecked += (object sender, RoutedEventArgs e) => { ((SettingBoolean)setting).Value = false; }; newSettingControl = checkBox; } else if (setting.GetType() == typeof(SettingOption)) { ComboBox comboBox = new ComboBox(); foreach (string option in ((SettingOption)setting).Options) { comboBox.Items.Add(option); } comboBox.SelectedValue = ((SettingOption)setting).GetSelected(); comboBox.SelectionChanged += (object sender, SelectionChangedEventArgs e) => { string selectedFilterName = (string)((ComboBox)sender).SelectedItem; ((SettingOption)setting).TrySetSelected(selectedFilterName); }; newSettingControl = comboBox; } settingsGrid.Children.Add(newSettingControl); newSettingControl?.SetValue(Grid.ColumnProperty, 1); newSettingControl?.SetValue(Slider.IsSnapToTickEnabledProperty, true); newSettingControl?.SetValue(Slider.TickFrequencyProperty, 1.0); newSettingControl?.SetValue(Grid.RowProperty, rowCount); rowCount++; } } }
public static void SetMaxTime(Control o, string value) { o.SetValue(MaxTimeProperty, value); }
/// <summary> /// Sets the value of the Dock attached property on the specified control. /// </summary> /// <param name="control">The control.</param> /// <param name="value">The value of the Dock property.</param> public static void SetDock(Control control, Dock value) { control.SetValue(DockProperty, value); }
public static void SetValue(Control o, TimeSpan value) { o.SetValue(ValueProperty, value); }
public static void SetTimeFormat(Control o, TimerFormats TimeFormat) { o.SetValue(TimeFormatProperty, TimeFormat); }
/// <summary> /// Sets the value of the IsTemplateFocusTargetProperty attached property on a control. /// </summary> /// <param name="control">The control.</param> /// <param name="value">The property value.</param> /// <remarks> /// When a control is navigated to using the keyboard, a focus adorner is shown - usually /// around the control itself. However if the TemplatedControl.IsTemplateFocusTarget /// attached property is set to true on an element in the control template, then the focus /// adorner will be shown around that control instead. /// </remarks> public void SetIsTemplateFocusTarget(Control control, bool value) { control.SetValue(IsTemplateFocusTargetProperty, value); }
public void Attach(MetaAction metaAction, Control control) { ValidateType(control); var existingItems = controlAction.Where(it => it.Item1 == metaAction); var targetItem = existingItems.FirstOrDefault(it => { Control c; if (it.Item2.TryGetTarget(out c)) { return(c.Equals(control)); } return(false); }); // already attached if (targetItem != null) { return; } Image image = null; if (metaAction.Icon != null) { image = ImageHelper.CreateImage(metaAction); image.MaxWidth = MetaAction.ToolBarIconSize; image.MaxHeight = MetaAction.ToolBarIconSize; } if (control is MenuItem) { var menu = (MenuItem)control; menu.Icon = image; menu.InputGestureText = metaAction.ShortCut; menu.Header = metaAction.Title; menu.ToolTip = metaAction.ToolTip; } if (control is ButtonBase) { var button = (ButtonBase)control; button.Content = image; button.ToolTip = metaAction.ToolTip; if (!string.IsNullOrEmpty(metaAction.ShortCut)) { button.ToolTip += ": " + metaAction.ShortCut; } } control.SetValue(ToolTipService.ShowOnDisabledProperty, true); // IsEnabled property // Visibility control.SetBinding(UIElement.VisibilityProperty, new Binding { Source = metaAction, Path = new PropertyPath("IsVisible"), Mode = BindingMode.OneWay, Converter = BooleanToVisibilityConverter.Instance, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); // Shortcut if (metaAction.KeyBinding != null) { var window = GetWindow(control); if (!window.InputBindings.Contains(metaAction.KeyBinding)) { window.InputBindings.Add(metaAction.KeyBinding); } } // Message.SetAttach(control, metaAction.CaliburnAction); control.SetValue(Message.AttachProperty, metaAction.CaliburnAction); controlAction.Add(new Tuple <MetaAction, WeakReference <Control> >(metaAction, new WeakReference <Control>(control))); }