internal static void SyncColumnProperty <T>(AvaloniaObject column, AvaloniaObject content, AvaloniaProperty <T> contentProperty, AvaloniaProperty <T> columnProperty) { if (!column.IsSet(columnProperty)) { content.ClearValue(contentProperty); } else { content.SetValue(contentProperty, column.GetValue(columnProperty)); } }
public static object UpdateDependencyColor(this AvaloniaObject depo, AvaloniaProperty dp, Color newColor) { if (!newColor.IsDefault) { depo.SetValue(dp, newColor.ToBrush()); } else { depo.ClearValue(dp); } return(depo.GetValue(dp)); }
/// <summary> /// Gets a diagnostic for a <see cref="AvaloniaProperty"/> on a <see cref="AvaloniaObject"/>. /// </summary> /// <param name="o">The object.</param> /// <param name="property">The property.</param> /// <returns> /// A <see cref="AvaloniaPropertyValue"/> that can be used to diagnose the state of the /// property on the object. /// </returns> public static AvaloniaPropertyValue GetDiagnostic(this AvaloniaObject o, AvaloniaProperty property) { var set = o.GetSetValues(); PriorityValue value; if (set.TryGetValue(property, out value)) { return(new AvaloniaPropertyValue( property, o.GetValue(property), (BindingPriority)value.ValuePriority, value.GetDiagnostic())); } else { return(new AvaloniaPropertyValue( property, o.GetValue(property), BindingPriority.Unset, "Unset")); } }
private Layoutable?GetDependencyElement(AvaloniaProperty property, AvaloniaObject child) { var dependency = child.GetValue(property); if (dependency is Layoutable layoutable) { if (Children.Contains((ILayoutable)layoutable)) { return(layoutable); } throw new ArgumentException($"RelativePanel error: Element does not exist in the current context: {property.Name}"); } return(null); }
/// <summary> /// Returns an <see cref="ObservableObject{T}"/> wrapper around the RegionContext value. The RegionContext /// will be set on any views (dependency objects) that are inside the <see cref="IRegion.Views"/> collection by /// the <see cref="Behaviors.BindRegionContextToAvaloniaObjectBehavior"/> Behavior. /// The RegionContext will also be set to the control that hosts the Region, by the <see cref="Behaviors.SyncRegionContextWithHostBehavior"/> Behavior. /// /// If the <see cref="ObservableObject{T}"/> wrapper does not already exist, an empty one will be created. This way, an observer can /// notify when the value is set for the first time. /// </summary> /// <param name="view">Any view that hold the RegionContext value. </param> /// <returns>Wrapper around the Regioncontext value. </returns> public static ObservableObject <object> GetObservableContext(AvaloniaObject view) { if (view == null) { throw new ArgumentNullException(nameof(view)); } ObservableObject <object> context = view.GetValue(ObservableRegionContextProperty) as ObservableObject <object>; if (context == null) { context = new ObservableObject <object>(); view.SetValue(ObservableRegionContextProperty, context); } return(context); }
/// <summary> /// Returns an <see cref="ObservableObject{T}"/> wrapper that can hold an <see cref="IRegion"/>. Using this wrapper /// you can detect when an <see cref="IRegion"/> has been created by the <see cref="RegionAdapterBase{T}"/>. /// /// If the <see cref="ObservableObject{T}"/> wrapper does not yet exist, a new wrapper will be created. When the region /// gets created and assigned to the wrapper, you can use the <see cref="ObservableObject{T}.PropertyChanged"/> event /// to get notified of that change. /// </summary> /// <param name="view">The view that will host the region. </param> /// <returns>Wrapper that can hold an <see cref="IRegion"/> value and can notify when the <see cref="IRegion"/> value changes. </returns> public static ObservableObject <IRegion> GetObservableRegion(AvaloniaObject view) { if (view == null) { throw new ArgumentNullException(nameof(view)); } ObservableObject <IRegion> regionWrapper = view.GetValue(ObservableRegionProperty) as ObservableObject <IRegion>; if (regionWrapper == null) { regionWrapper = new ObservableObject <IRegion>(); view.SetValue(ObservableRegionProperty, regionWrapper); } return(regionWrapper); }
private IEnumerable <(AvaloniaProperty, object)> CollectChangedValue(AvaloniaObject obj, IEnumerable <AvaloniaProperty> aprops) { foreach (var aprop in aprops) { if (aprop.Name == "Parent") { continue; } if (aprop.IsReadOnly) { continue; } if (obj.IsSet(aprop)) { var objValue = obj.GetValue(aprop); yield return(aprop, objValue); } } }
/// <summary> /// Gets the value of the Bottom attached property for a control. /// </summary> /// <param name="element">The control.</param> /// <returns>The control's bottom coordinate.</returns> public static double GetBottom(AvaloniaObject element) { return element.GetValue(BottomProperty); }
/// <summary> /// Gets renderer attached property. /// </summary> /// <param name="obj">The avalonia object.</param> /// <returns>The shape renderer property.</returns> public static IShapeRenderer GetRenderer(AvaloniaObject obj) { return(obj.GetValue(RendererProperty)); }
public static string GetName(AvaloniaObject avaloniaObject) => avaloniaObject.GetValue(NameProperty);
/// <summary> /// Gets the value of the RowSpan attached property for a control. /// </summary> /// <param name="element">The control.</param> /// <returns>The control's row span.</returns> public static int GetRowSpan(AvaloniaObject element) { return(element.GetValue(RowSpanProperty)); }
public static string GetFoo(AvaloniaObject target) => (string)target.GetValue(FooProperty);
public static bool GetShowAlternation(AvaloniaObject obj) { return((bool)obj.GetValue(ShowAlternationProperty)); }
/// <summary> /// Gets renderer options attached property. /// </summary> /// <param name="obj">The avalonia object.</param> /// <returns>The shape renderer property.</returns> public static ShapeRenderer GetRenderer(AvaloniaObject obj) { return obj.GetValue(RendererProperty); }
/// <summary> /// Gets the value of the Top attached property for a control. /// </summary> /// <param name="element">The control.</param> /// <returns>The control's top coordinate.</returns> public static double GetTop(AvaloniaObject element) { return element.GetValue(TopProperty); }
/// <summary> /// Gets the value of the RowSpan attached property for a control. /// </summary> /// <param name="element">The control.</param> /// <returns>The control's row span.</returns> public static int GetRowSpan(AvaloniaObject element) { return element.GetValue(RowSpanProperty); }
/// <summary> /// Gets the value of the Column attached property for a control. /// </summary> /// <param name="element">The control.</param> /// <returns>The control's column.</returns> public static int GetColumn(AvaloniaObject element) { return element.GetValue(ColumnProperty); }
public static SolidColorBrush GetSwitchTrackOffBackground(AvaloniaObject element) { return((SolidColorBrush)element.GetValue(SwitchTrackOffBackgroundProperty)); }
public static bool GetIsFileDragDropEnabled(AvaloniaObject obj) { return((bool)obj.GetValue(IsFileDragDropEnabledProperty)); }
public static string GetLabel(AvaloniaObject element) => (string)element.GetValue(LabelProperty);
/// <summary> /// Gets the value of the Right attached property for a control. /// </summary> /// <param name="element">The control.</param> /// <returns>The control's right coordinate.</returns> public static double GetRight(AvaloniaObject element) { return element.GetValue(RightProperty); }
/// <summary> /// Gets the value of the BitmapInterpolationMode attached property for a control. /// </summary> /// <param name="element">The control.</param> /// <returns>The control's left coordinate.</returns> public static BitmapInterpolationMode GetBitmapInterpolationMode(AvaloniaObject element) { return(element.GetValue(BitmapInterpolationModeProperty)); }
public static ICommand GetCommand(AvaloniaObject element) { return(element.GetValue(CommandProperty)); }
public static KeyGesture GetHotKey(AvaloniaObject target) => target.GetValue(HotKeyProperty);
public static object GetAlignRightWith(AvaloniaObject obj) { return((object)obj.GetValue(AlignRightWithProperty)); }
public static bool GetFileDragDropTarget(AvaloniaObject obj) { return((bool)obj.GetValue(FileDragDropTargetProperty)); }
public static bool GetAlignVerticalCenterWithPanel(AvaloniaObject obj) { return((bool)obj.GetValue(AlignVerticalCenterWithPanelProperty)); }
public static ISelection GetSelection(AvaloniaObject obj) { return(obj.GetValue(SelectionProperty)); }
public static object GetAlignVerticalCenterWith(AvaloniaObject obj) { return((object)obj.GetValue(AlignVerticalCenterWithProperty)); }
/// <summary> /// Gets the value of the Column attached property for a control. /// </summary> /// <param name="element">The control.</param> /// <returns>The control's column.</returns> public static int GetColumn(AvaloniaObject element) { return(element.GetValue(ColumnProperty)); }
public static object GetBelow(AvaloniaObject obj) { return((object)obj.GetValue(BelowProperty)); }
public static NativeMenu GetMenu(AvaloniaObject o) => o.GetValue(MenuProperty);
public static object GetAbove(AvaloniaObject obj) { return((object)obj.GetValue(AboveProperty)); }
public static KeyGesture GetHotKey(AvaloniaObject target) => target.GetValue(HotKeyProperty);
public static object GetRightOf(AvaloniaObject obj) { return((object)obj.GetValue(RightOfProperty)); }
/// <summary> /// Gets data flow attached property. /// </summary> /// <param name="obj">The avalonia object.</param> /// <returns>The data flow property.</returns> public static IDataFlow GetDataFlow(AvaloniaObject obj) { return(obj.GetValue(DataFlowProperty)); }
public static bool GetAlignBottomWithPanel(AvaloniaObject obj) { return((bool)obj.GetValue(AlignBottomWithPanelProperty)); }