Пример #1
0
        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());
        }
Пример #2
0
 static RibbonGroupBox()
 {
     CommandProperty = AvaloniaProperty.RegisterDirect <RibbonGroupBox, ICommand>(nameof(Command), button => button.Command, (button, command) => button.Command = command, enableDataValidation: true);
 }
Пример #3
0
 static RibbonGroup()
 {
     HeaderProperty = AvaloniaProperty.RegisterDirect <RibbonGroup, string>(nameof(Header), o => o.Header, (o, v) => o.Header = v);
 }
Пример #4
0
 static Ribbon()
 {
     IsExpandedProperty        = AvaloniaProperty.RegisterDirect <Ribbon, bool>(nameof(IsExpanded), o => o.IsExpanded, (o, v) => o.IsExpanded = v, true);
     HelpButtonCommandProperty = AvaloniaProperty.RegisterDirect <Ribbon, ICommand>(nameof(HelpButtonCommand), o => o.HelpButtonCommand, (o, v) => o.HelpButtonCommand = v);
 }
Пример #5
0
 static Hyperlink()
 {
     UrlProperty = AvaloniaProperty.RegisterDirect <Hyperlink, Uri>(nameof(Url), o => o.Url, (o, v) => o.Url = v, null);
 }
Пример #6
0
 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);
 }