Skip to content

Commit

Permalink
(GH-3910) Allow set the navigation button style
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Nov 24, 2020
1 parent eff2079 commit 639af46
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
17 changes: 17 additions & 0 deletions src/MahApps.Metro/Controls/FlipView.cs
Expand Up @@ -26,6 +26,7 @@ namespace MahApps.Metro.Controls
[TemplatePart(Name = PART_DownButton, Type = typeof(Button))]
[TemplatePart(Name = PART_BannerGrid, Type = typeof(Grid))]
[TemplatePart(Name = PART_BannerLabel, Type = typeof(Label))]
[StyleTypedProperty(Property = nameof(NavigationButtonStyle), StyleTargetType = typeof(Button))]
public class FlipView : Selector
{
/// <summary>Identifies the <see cref="MouseHoverBorderBrush"/> dependency property.</summary>
Expand Down Expand Up @@ -381,6 +382,22 @@ public double BannerOpacity
set => this.SetValue(BannerOpacityProperty, value);
}

/// <summary>Identifies the <see cref="NavigationButtonStyle"/> dependency property.</summary>
public static readonly DependencyProperty NavigationButtonStyleProperty
= DependencyProperty.Register(nameof(NavigationButtonStyle),
typeof(Style),
typeof(FlipView),
new PropertyMetadata(null));

/// <summary>
/// Gets or sets the <see cref="FrameworkElement.Style"/> for the navigation buttons.
/// </summary>
public Style NavigationButtonStyle
{
get => (Style)this.GetValue(NavigationButtonStyleProperty);
set => this.SetValue(NavigationButtonStyleProperty, value);
}

/// <summary>Identifies the <see cref="ButtonBackContent"/> dependency property.</summary>
public static readonly DependencyProperty ButtonBackContentProperty
= DependencyProperty.Register(nameof(ButtonBackContent),
Expand Down
11 changes: 6 additions & 5 deletions src/MahApps.Metro/Themes/FlipView.xaml
Expand Up @@ -73,7 +73,7 @@
Content="{TemplateBinding ButtonBackContent}"
ContentStringFormat="{TemplateBinding ButtonBackContentStringFormat}"
ContentTemplate="{TemplateBinding ButtonBackContentTemplate}"
Style="{DynamicResource MahApps.Styles.Button.FlipView.Navigation}"
Style="{TemplateBinding NavigationButtonStyle}"
Visibility="Hidden" />
<Button x:Name="PART_ForwardButton"
Grid.Row="1"
Expand All @@ -84,7 +84,7 @@
Content="{TemplateBinding ButtonForwardContent}"
ContentStringFormat="{TemplateBinding ButtonForwardContentStringFormat}"
ContentTemplate="{TemplateBinding ButtonForwardContentTemplate}"
Style="{DynamicResource MahApps.Styles.Button.FlipView.Navigation}"
Style="{TemplateBinding NavigationButtonStyle}"
Visibility="Hidden" />

<Button x:Name="PART_UpButton"
Expand All @@ -96,7 +96,7 @@
Content="{TemplateBinding ButtonUpContent}"
ContentStringFormat="{TemplateBinding ButtonUpContentStringFormat}"
ContentTemplate="{TemplateBinding ButtonUpContentTemplate}"
Style="{DynamicResource MahApps.Styles.Button.FlipView.Navigation}"
Style="{TemplateBinding NavigationButtonStyle}"
Visibility="Hidden" />
<Button x:Name="PART_DownButton"
Grid.Row="1"
Expand All @@ -107,7 +107,7 @@
Content="{TemplateBinding ButtonDownContent}"
ContentStringFormat="{TemplateBinding ButtonDownContentStringFormat}"
ContentTemplate="{TemplateBinding ButtonDownContentTemplate}"
Style="{DynamicResource MahApps.Styles.Button.FlipView.Navigation}"
Style="{TemplateBinding NavigationButtonStyle}"
Visibility="Hidden" />

<Grid x:Name="PART_BannerGrid"
Expand All @@ -119,9 +119,9 @@
Background="{TemplateBinding BannerBackground}"
Opacity="{TemplateBinding BannerOpacity}">
<Label x:Name="PART_BannerLabel"
ContentStringFormat="{TemplateBinding BannerTextStringFormat}"
ContentTemplate="{TemplateBinding BannerTextTemplate}"
ContentTemplateSelector="{TemplateBinding BannerTextTemplateSelector}"
ContentStringFormat="{TemplateBinding BannerTextStringFormat}"
FontFamily="{TemplateBinding FontFamily}"
FontSize="{TemplateBinding FontSize}"
Foreground="{TemplateBinding BannerForeground}"
Expand Down Expand Up @@ -316,6 +316,7 @@
<Setter Property="KeyboardNavigation.DirectionalNavigation" Value="Cycle" />
<Setter Property="MinHeight" Value="100" />
<Setter Property="MinWidth" Value="100" />
<Setter Property="NavigationButtonStyle" Value="{DynamicResource MahApps.Styles.Button.FlipView.Navigation}" />
<Setter Property="Selector.IsSynchronizedWithCurrentItem" Value="True" />
<Setter Property="Template" Value="{StaticResource MahApps.Templates.FlipView}" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
Expand Down

0 comments on commit 639af46

Please sign in to comment.