diff --git a/components/Ribbon/samples/RibbonCustomSample.xaml b/components/Ribbon/samples/RibbonCustomSample.xaml index e7d6a27bf..3277c8599 100644 --- a/components/Ribbon/samples/RibbonCustomSample.xaml +++ b/components/Ribbon/samples/RibbonCustomSample.xaml @@ -27,7 +27,16 @@ - + + + + + + + + SetValue(ScrollStepProperty, value); } + /// + /// The DP to store the property value. + /// + public static readonly DependencyProperty OptionsFlyoutProperty = DependencyProperty.Register( + nameof(OptionsFlyout), + typeof(FlyoutBase), + typeof(Ribbon), + new PropertyMetadata(null, OnOptionsFlyoutPropertyChanged)); + + /// + /// The flyout to display when the user clicks on the ribbon options button. + /// + public FlyoutBase? OptionsFlyout + { + get => (FlyoutBase?)GetValue(OptionsFlyoutProperty); + set => SetValue(OptionsFlyoutProperty, value); + } + + /// + /// The DP to store the property value. + /// + public static readonly DependencyProperty OptionsAccessibleNameProperty = DependencyProperty.Register( + nameof(OptionsAccessibleName), + typeof(string), + typeof(Ribbon), + new PropertyMetadata(string.Empty)); + + /// + /// The accessible name for the options button. + /// + public string OptionsAccessibleName + { + get => (string)GetValue(OptionsAccessibleNameProperty); + set => SetValue(OptionsAccessibleNameProperty, value); + } + + /// + /// The DP to store the property value. + /// + public static readonly DependencyProperty OptionsAccessKeyProperty = DependencyProperty.Register( + nameof(OptionsAccessKey), + typeof(string), + typeof(Ribbon), + new PropertyMetadata(string.Empty)); + + /// + /// The access key to set on the options flyout button. + /// + public string OptionsAccessKey + { + get => (string)GetValue(OptionsAccessKeyProperty); + set => SetValue(OptionsAccessKeyProperty, value); + } + public Ribbon() { DefaultStyleKey = typeof(Ribbon); @@ -97,6 +156,8 @@ protected override void OnApplyTemplate() _scrollViewer.SizeChanged += OnSizeChanged; UpdateScrollButtonsState(); } + + UpdateOptionsFlyoutState(); } private void OnItemsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) @@ -198,4 +259,15 @@ private void OnDecrementScrollViewer(object sender, RoutedEventArgs e) private void OnIncrementScrollViewer(object sender, RoutedEventArgs e) => _scrollViewer?.ChangeView(_scrollViewer.HorizontalOffset + ScrollStep, verticalOffset: null, zoomFactor: null); + + private static void OnOptionsFlyoutPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var ribbon = (Ribbon)d; + ribbon.UpdateOptionsFlyoutState(); + } + + private void UpdateOptionsFlyoutState() => VisualStateManager.GoToState( + this, + OptionsFlyout != null ? OptionsVisibleStateTemplatePart : OptionsCollapsedStateTemplatePart, + useTransitions: true); } diff --git a/components/Ribbon/src/RibbonStyle.xaml b/components/Ribbon/src/RibbonStyle.xaml index 9fe9a5468..31cf64638 100644 --- a/components/Ribbon/src/RibbonStyle.xaml +++ b/components/Ribbon/src/RibbonStyle.xaml @@ -358,6 +358,7 @@ + @@ -380,6 +381,14 @@ + + + + + + + + + +