public static StyledProperty <TValue> Register <TOwner, TValue>(string name, TValue defaultValue = default, PropertyOptions options = PropertyOptions.None, Action <TOwner, CommonPropertyChangedArgs <TValue> > onChanged = null) where TOwner : AvaloniaObject { var property = AvaloniaProperty.Register <TOwner, TValue>(name, defaultValue, options.Has(PropertyOptions.Inherits), options.Has(PropertyOptions.BindsTwoWay) ? Avalonia.Data.BindingMode.TwoWay : Avalonia.Data.BindingMode.OneWay); if (options.Has(PropertyOptions.AffectsRender)) { AffectsRender(new[] { property }); } if (options.Has(PropertyOptions.AffectsArrange)) { AffectsArrange(new[] { property }); } if (options.Has(PropertyOptions.AffectsMeasure)) { AffectsMeasure(new[] { property }); } if (onChanged != null) { property.Changed.AddClassHandler <TOwner>( (o, e) => onChanged(o, new CommonPropertyChangedArgs <TValue>((TValue)e.OldValue, (TValue)e.NewValue))); } return(property); }
/*public static readonly StyledProperty<WindowState> WindowStateProperty; * public WindowState WindowState * { * get => GetValue(WindowStateProperty); * set => SetValue(WindowStateProperty, value); * } * * public static readonly DirectProperty<RibbonWindow, bool> IsActiveProperty; * public bool IsActive * { * get => GetValue(IsActiveProperty); * set => SetValue(IsActiveProperty, value); * }*/ static RibbonWindow() { TitleBarBackgroundProperty = AvaloniaProperty.Register <RibbonWindow, IBrush>(nameof(TitleBarBackground)); TitleBarForegroundProperty = AvaloniaProperty.Register <RibbonWindow, IBrush>(nameof(TitleBarForeground)); /*WindowStateProperty = Window.WindowStateProperty.AddOwner<RibbonWindow>(); * IsActiveProperty = Window.IsActiveProperty.AddOwner<RibbonWindow>(x => x.IsActive, (x, o) => x.IsActive = o);*/ //HasSystemDecorationsProperty.OverrideDefaultValue(typeof(RibbonWindow), false); }
static RibbonComboButton() { ContentProperty = RibbonButton.ContentProperty.AddOwner <RibbonComboButton>(); IconProperty = RibbonButton.IconProperty.AddOwner <RibbonComboButton>(); LargeIconProperty = AvaloniaProperty.Register <RibbonButton, object>(nameof(LargeIcon), null); SizeProperty = RibbonButton.SizeProperty.AddOwner <RibbonComboButton>(); CanAddToQuickAccessToolbarProperty = RibbonButton.CanAddToQuickAccessToolbarProperty.AddOwner <RibbonComboButton>(); CommandProperty = Button.CommandProperty.AddOwner <RibbonComboButton>(button => button.Command, (button, command) => button.Command = command); CommandParameterProperty = Button.CommandParameterProperty.AddOwner <RibbonComboButton>(); }
static Ribbon() { OrientationProperty = StackLayout.OrientationProperty.AddOwner <Ribbon>(); OrientationProperty.OverrideDefaultValue <Ribbon>(Orientation.Horizontal); HeaderBackgroundProperty = AvaloniaProperty.Register <Ribbon, IBrush>(nameof(HeaderBackground)); HeaderForegroundProperty = AvaloniaProperty.Register <Ribbon, IBrush>(nameof(HeaderForeground)); IsCollapsedProperty = AvaloniaProperty.Register <Ribbon, bool>(nameof(IsCollapsed)); IsMenuOpenProperty = AvaloniaProperty.Register <Ribbon, bool>(nameof(IsMenuOpen)); MenuItemsProperty = MenuBase.ItemsProperty.AddOwner <Ribbon>(x => x.MenuItems, (x, v) => x.MenuItems = v); MenuPlacesItemsProperty = ItemsControl.ItemsProperty.AddOwner <Ribbon>(x => x.MenuPlacesItems, (x, v) => x.MenuPlacesItems = v); }
public static AvaloniaProperty Register <TOwner, T>(string name, T def, Action <AvaloniaObject, AvaloniaPropertyChangedEventArgs> changed) where TOwner : AvaloniaObject { var pp = AvaloniaProperty.Register <TOwner, T>(name, def); Action <AvaloniaPropertyChangedEventArgs> cb = args => { changed(args.Sender, args); }; pp.Changed.Subscribe(cb); return(pp); }
static Ribbon() { OrientationProperty = StackLayout.OrientationProperty.AddOwner <Ribbon>(); OrientationProperty.OverrideDefaultValue <Ribbon>(Orientation.Horizontal); HeaderBackgroundProperty = AvaloniaProperty.Register <Ribbon, IBrush>(nameof(HeaderBackground)); HeaderForegroundProperty = AvaloniaProperty.Register <Ribbon, IBrush>(nameof(HeaderForeground)); IsCollapsedProperty = AvaloniaProperty.Register <Ribbon, bool>(nameof(IsCollapsed)); IsCollapsedPopupOpenProperty = AvaloniaProperty.Register <Ribbon, bool>(nameof(IsCollapsedPopupOpen)); IsMenuOpenProperty = AvaloniaProperty.Register <Ribbon, bool>(nameof(IsMenuOpen)); SelectedIndexProperty.Changed.AddClassHandler <Ribbon>((x, e) => { if (((int)e.NewValue >= 0) && (x.SelectedItem != null) && (x.SelectedItem is RibbonTab tab)) { x.SelectedGroups = tab.Groups; } else { x.SelectedGroups = new AvaloniaList <object>(); } }); IsCollapsedProperty.Changed.AddClassHandler(new Action <Ribbon, AvaloniaPropertyChangedEventArgs>((sneder, args) => { sneder.UpdatePresenterLocation((bool)args.NewValue); })); AccessKeyHandler.AccessKeyPressedEvent.AddClassHandler <Ribbon>((sender, e) => { if (e.Source is Control ctrl) { (sender as Ribbon).HandleKeyTipControl(ctrl); } }); KeyTip.ShowChildKeyTipKeysProperty.Changed.AddClassHandler <Ribbon>(new Action <Ribbon, AvaloniaPropertyChangedEventArgs>((sender, args) => { bool isOpen = (bool)args.NewValue; if (isOpen) { sender.Focus(); } sender.SetChildKeyTipsVisibility(isOpen); })); HelpButtonCommandProperty = AvaloniaProperty.RegisterDirect <Ribbon, ICommand>(nameof(HelpButtonCommand), o => o.HelpButtonCommand, (o, v) => o.HelpButtonCommand = v); BoundsProperty.Changed.AddClassHandler <RibbonGroupsStackPanel>((sender, e) => sender.InvalidateMeasure()); }
/// <summary> /// The static <see cref="NativeWindowHost"/> constructor. /// </summary> static NativeWindowHost() { // Set default value of FocusableProperty to true. FocusableProperty.OverrideMetadata(typeof(NativeWindowHost), new StyledPropertyMetadata <bool>(true)); // Register IgnoreNativeWindowRectProperty. NativeWindowHost.IgnoreNativeWindowRectProperty = AvaloniaProperty.Register <NativeWindowHost, bool>( "IgnoreNativeWindowRect"); // Property IgnoreNativeWindowRectProperty affects measurement Avalonia.Layout.Layoutable.AffectsMeasure( new AvaloniaProperty[] { NativeWindowHost.IgnoreNativeWindowRectProperty } ); }
static RibbonSplitButton() { ContentProperty = RibbonButton.ContentProperty.AddOwner <RibbonSplitButton>(); IconProperty = RibbonButton.IconProperty.AddOwner <RibbonSplitButton>(); LargeIconProperty = AvaloniaProperty.Register <RibbonButton, object>(nameof(LargeIcon), null); //SizeProperty = RibbonButton.SizeProperty.AddOwner<RibbonComboButton>(); //MinSizeProperty = RibbonButton.MinSizeProperty.AddOwner<RibbonComboButton>(); //MaxSizeProperty = RibbonButton.MaxSizeProperty.AddOwner<RibbonComboButton>(); //CanAddToQuickAccessToolbarProperty = RibbonButton.CanAddToQuickAccessToolbarProperty.AddOwner<RibbonComboButton>(); CommandProperty = Button.CommandProperty.AddOwner <RibbonSplitButton>(button => button.Command, (button, command) => button.Command = command); CommandParameterProperty = Button.CommandParameterProperty.AddOwner <RibbonSplitButton>(); //AffectsRender<RibbonComboButton>(SizeProperty, MinSizeProperty, MaxSizeProperty); //AffectsMeasure<RibbonComboButton>(SizeProperty, MinSizeProperty, MaxSizeProperty); //AffectsArrange<RibbonComboButton>(SizeProperty, MinSizeProperty, MaxSizeProperty); //RibbonControLHelper<RibbonComboButton>.AddHandlers(MinSizeProperty, MaxSizeProperty); RibbonControlHelper <RibbonSplitButton> .SetProperties(out SizeProperty, out MinSizeProperty, out MaxSizeProperty); Button.FocusableProperty.OverrideDefaultValue <RibbonSplitButton>(false); }
/*public static AvaloniaProperty Register<TOwner, T>(string name, T def, Action<AvaloniaObject, AvaloniaPropertyChangedEventArgs> changed) where TOwner : AvaloniaObject * { * var pp = AvaloniaProperty.Register<TOwner, T>(name, def); * Action<AvaloniaPropertyChangedEventArgs> cb = args => * { * changed(args.Sender, args); * }; * * pp.Changed.Subscribe(cb); * return pp; * } * * * */public static AvaloniaProperty Register <TOwner, T>(string name, T def, Action <IAvaloniaObject, AvaloniaPropertyChangedEventArgs> changed) where TOwner : IAvaloniaObject { var pp = AvaloniaProperty.Register <TOwner, T>(name, def); /*IObserver<AvaloniaPropertyChangedEventArgs> cb = new Observer<AvaloniaPropertyChangedEventArgs>.Create((args) => * { * changed(args.Sender, args); * });*/ pp.Changed.Subscribe(args => { changed.Invoke(args.Sender, args); /*if ((args != null) && (args.Sender != null) && (changed != null)) * changed(args.Sender, args);*/ }); //pp.Changed.Subscribe(changed); return(pp); }
static RibbonView() { IsRibbonExpandedProperty = AvaloniaProperty.Register <RibbonView, bool>(nameof(IsRibbonExpanded), true); }
static RibbonControl() { RemainingTabControlHeaderColorProperty = AvaloniaProperty.Register <RibbonControl, IBrush>(nameof(RemainingTabControlHeaderColor)); }
static RibbonWindow() { TitleBarBackgroundProperty = AvaloniaProperty.Register <RibbonWindow, IBrush>(nameof(TitleBarBackground)); TitleBarForegroundProperty = AvaloniaProperty.Register <RibbonWindow, IBrush>(nameof(TitleBarForeground)); }
static RibbonTabGroup() { TextProperty = AvaloniaProperty.Register <RibbonTabGroup, string>(nameof(Text)); CommandProperty = AvaloniaProperty.RegisterDirect <RibbonTabGroup, ICommand>(nameof(Command), button => button.Command, (button, command) => button.Command = command, enableDataValidation: true); }
static RibbonWindow() { TitleBarColorProperty = AvaloniaProperty.Register <RibbonWindow, IBrush>(nameof(TitleBarColor)); }
static RibbonButton() { SizeProperty = AvaloniaProperty.Register <RibbonButton, RibbonControlSize>(nameof(RibbonControlSize), RibbonControlSize.Large); CanAddToQuickAccessToolbarProperty = AvaloniaProperty.Register <RibbonButton, bool>(nameof(CanAddToQuickAccessToolbar), true); }
static RibbonButton() { TextProperty = AvaloniaProperty.Register <RibbonButton, string>(nameof(Text)); IconPathProperty = AvaloniaProperty.Register <RibbonButton, IBitmap>(nameof(IconPath)); }
static GroupBox() { HeaderProperty = AvaloniaProperty.Register <GroupBox, string>(nameof(Header)); }
static StyledWindow() { HeaderContentProperty = AvaloniaProperty.Register <StyledWindow, object>(nameof(HeaderContent)); IsModalProperty = AvaloniaProperty.Register <StyledWindow, bool>(nameof(IsModal)); }