/// <summary> /// Gets spell checking culture of the specified control. /// </summary> /// <param name="control"> /// The control. /// </param> /// <returns> /// The spell checking culture. /// </returns> /// <exception cref="ArgumentNullException"> /// The <paramref name="control"/> parameter is null. /// </exception> public static CultureInfo GetCulture(Control control) { if (control == null) throw new ArgumentNullException("control"); return (CultureInfo)control.GetValue(CultureProperty); }
/// <summary> /// Gets the IsSendingMouseWheelEventToParent for a given <see cref="TextBox"/>. /// </summary> /// <param name="control"> /// The <see cref="TextBox"/> whose IsSendingMouseWheelEventToParent is to be retrieved. /// </param> /// <returns> /// The IsSendingMouseWheelEventToParent, or <see langword="null"/> /// if no IsSendingMouseWheelEventToParent has been set. /// </returns> public static bool? GetIsSendingMouseWheelEventToParent(Control control) { if (control == null) throw new ArgumentNullException(""); return control.GetValue(ScrollProperty) as bool?; }
private static DoubleClickCommandBehavior GetOrCreateBehavior(Control control) { var behavior = control.GetValue(DoubleClickCommandBehaviorProperty) as DoubleClickCommandBehavior; if (behavior == null) { behavior = new DoubleClickCommandBehavior(control); control.SetValue(DoubleClickCommandBehaviorProperty, behavior); } return behavior; }
/// <summary> /// This method retrieves the default style key of a control. /// </summary> /// <param name="control">The control to retrieve the default style key /// from.</param> /// <returns>The default style key of the control.</returns> public static object GetDefaultStyleKey(Control control) { return control.GetValue(Control.DefaultStyleKeyProperty); }
public static double GetOneWayControlHeight(Control element) { return (double)element.GetValue(OneWayControlHeightProperty); }
private static Guid GetOperationId(Control control) { return (Guid)control.GetValue(OperationIdProperty); }
public static bool GetShiftWheelScrollsHorizontally(Control element) => (bool)element.GetValue(ShiftWheelScrollsHorizontallyProperty);
public static bool GetFocusOnFirstElement(Control control) { return (bool)control.GetValue(FocusOnFirstElementProperty); }
void selectedDevice_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { selectedDevice = (Control)sender; selectedDevice.CaptureMouse(); deltaX = e.GetPosition(grdDeviceLayer).X - ((Thickness)selectedDevice.GetValue(Grid.MarginProperty)).Left; deltaY = e.GetPosition(grdDeviceLayer).Y - ((Thickness)selectedDevice.GetValue(Grid.MarginProperty)).Top; UnSelectAllDevice(); (sender as I_IO).IsSelect = true; this.grdSetting.DataContext = selectedDevice.DataContext; // throw new NotImplementedException(); }
void VisualInheritanceCore (Control c1, DependencyProperty prop1, FrameworkElement c2, DependencyProperty prop2, object value, object other) { Assert.AreSame (c1, c2.Parent, "#parented"); Assert.AreNotEqual (value, c1.GetValue (prop1), "#1"); Assert.AreNotEqual (value, c2.GetValue (prop2), "#2"); Assert.IsNull (VisualTreeHelper.GetParent (c2), "#c2 no parent"); Assert.AreEqual (0, VisualTreeHelper.GetChildrenCount (c1), "#c1 no children"); c1.SetValue (prop1, value); Assert.IsNotNull (c1.GetValue (prop1), "#3"); Assert.IsNotNull (c2.GetValue (prop2), "#4"); Assert.AreNotEqual (c1.GetValue (prop1), c2.GetValue (prop2), "#5"); // Once we connect c2 to c1 via the template visual tree, it will inherit the value CreateAsyncTest (c1, () => { c1.ApplyTemplate (); }, () => { Assert.AreEqual (c1.GetValue (prop1), c2.GetValue (prop2), "#6"); // And if we change the value inside the template, it affects c2 var visualParent = (FrameworkElement) VisualTreeHelper.GetChild (c1, 0); visualParent.SetValue (prop1, other); Assert.AreEqual (c2.GetValue (prop2), other, "#7"); } ); }
public static bool GetOpenShellContextMenu(Control control) { return (bool)control.GetValue(OpenShellContextMenuProperty); }
public static bool GetInterceptKeySelectionEvents(Control element) { return (bool)element.GetValue(InterceptKeySelectionEventsProperty); }
public static object GetParameter(Control target) { return target.GetValue(ParameterProperty); }
public static ICommand GetCommand(Control target) { return (ICommand)target.GetValue(CommandProperty); }
/// <summary> /// Gets a value indicating whether the control should receive focus on Loaded event. /// </summary> /// <param name="control"> /// The control. /// </param> /// <returns> /// <c>true</c> if the control should receive focus on Loaded event; otherwise, <c>false</c>. /// </returns> /// <exception cref="ArgumentNullException"> /// The <paramref name="control"/> parameter is null. /// </exception> public static bool GetFocusOnLoaded(Control control) { if (control == null) throw new ArgumentNullException("control"); return (bool)control.GetValue(FocusOnLoadedProperty); }
private static AutoComplete EnsureInstance( Control ctrl ) { var ac = ( AutoComplete )ctrl.GetValue( AutoComplete.AutoCompleteInstance ); if( ac == null ) { ac = new AutoComplete( ctrl ); //ac.SetControl( ctrl ); ctrl.SetValue( AutoCompleteInstancePropertyKey, ac ); } return ac; }
public static string GetStateName(Control o) { return (string)o.GetValue(StateNameProperty); }
void LogicalInheritanceCore (Control c1, DependencyProperty prop1, FrameworkElement c2, DependencyProperty prop2, object value, object other) { // Check that we inherit values even if the visual tree doesn't exist, // i.e. if we use logical inheritance. Assert.AreNotEqual (value, c1.GetValue (prop1), "#1"); Assert.AreNotEqual (value, c2.GetValue (prop2), "#2"); Assert.IsNull (VisualTreeHelper.GetParent (c2), "#c2 no parent"); Assert.AreEqual (0, VisualTreeHelper.GetChildrenCount (c1), "#c1 no children"); c1.SetValue (prop1, value); Assert.IsNotNull (c1.GetValue (prop1), "#3"); Assert.IsNotNull (c2.GetValue (prop2), "#4"); Assert.AreEqual (c1.GetValue (prop1), c2.GetValue (prop2), "#5"); // Now generate a visual tree with 'c2' at the end and check that the visual // tree doesn't affect which value is inherited CreateAsyncTest (c1, () => { c1.ApplyTemplate (); }, () => { var visualParent = (FrameworkElement) VisualTreeHelper.GetChild (c1, 0); visualParent.SetValue (prop1, other); Assert.AreEqual (c2.GetValue (prop2), value, "#6"); } ); }
public static bool GetWPFFocusFirst(Control control) { return (bool)control.GetValue(WPFFocusFirstProperty); }
private static void Subscribe(Control control, DependencyProperty property) { var binding = BindingOperations.GetBinding(control, property); if (binding != null && binding.IsBoundToDataContext()) { if (!binding.IsNotifiying()) { binding = binding.CreateNotifying(control.DataContext); BindingOperations.ClearBinding(control, property); BindingOperations.SetBinding(control, property, binding); } control.SourceUpdated += (o, args) => { if (args.Property == property) { var undoManager = GetUndoManager(control); var value = control.GetValue(property); undoManager._history.Update(control, value, property, UpdateReason.UserInput); } }; control.TargetUpdated += (o, args) => { if (args.Property == property) { var undoManager = GetUndoManager(control); var value = control.GetValue(property); undoManager._history.Update(control, value, property, UpdateReason.DataUpdated); } }; } }
private static CommandBehaviorBase<Control> GetOrCreateBehavior(Control control) { var behavior = control.GetValue(EventCommandBehaviorProperty) as CommandBehaviorBase<Control>; if (behavior == null) { behavior = CreateCommandBehavior(control, control.GetValue(EventNameProperty).ToString()); control.SetValue(EventCommandBehaviorProperty, behavior); } return behavior; }
/// <summary> /// 获取外层的控件。 /// /// DesignerItem 返回 BlockControl。 /// Connection 返回 Controls.Connection /// </summary> /// <param name="element"></param> /// <returns></returns> public static IModelingDesignerComponent GetComponent(Control element) { return element.GetValue(ComponentProperty) as IModelingDesignerComponent; }
/// <summary> /// Gets the value in EventName attached property on the provided <see cref="Control"/>. /// </summary> /// <param name="control">The DependencyObject that has the EventName.</param> /// <returns>The value of the property.</returns> public static String GetEventName(Control control) { return control.GetValue(EventNameProperty).ToString(); }
public static bool GetIsControlSizeBound(Control element) { return (bool)element.GetValue(IsControlSizeBoundProperty); }
public static EnabledOpacity GetEnabledOpacity(Control element) { return (EnabledOpacity)element.GetValue(EnabledOpacityProperty); }
public static double GetOneWayControlWidth(Control element) { return (double)element.GetValue(OneWayControlWidthProperty); }
public static ICommand GetDoubleClickCommand(Control element) { return (ICommand)element.GetValue(DoubleClickCommandProperty); }
public static ICommand GetCommand(Control control) { return control.GetValue(CommandProperty) as ICommand; }
public static object GetDoubleClickCommandParameter(Control element) { return element.GetValue(DoubleClickCommandParameterProperty); }
/// <summary> /// Gets the visual state associated with the specified control. /// </summary> /// <param name="control">The control to lookup.</param> /// <returns>The current visual state as it was last set.</returns> public static string GetVisualState(Control control) { return (string)control.GetValue(VisualStateProperty); }
public static object GetCommandParameter(Control control) { return control.GetValue(CommandParameterProperty); }