Browse Source

Add Fluent v1 default style for SplitButton

pull/7422/head
robloo 5 years ago
parent
commit
63f1aa8cd6
  1. 141
      src/Avalonia.Controls/SplitButton/SplitButton.cs
  2. 27
      src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml
  3. 27
      src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml
  4. 1
      src/Avalonia.Themes.Fluent/Controls/FluentControls.xaml
  5. 370
      src/Avalonia.Themes.Fluent/Controls/SplitButton.xaml

141
src/Avalonia.Controls/SplitButton/SplitButton.cs

@ -1,6 +1,7 @@
using System;
using System.Reactive.Disposables;
using System.Windows.Input;
using Avalonia.Controls.Metadata;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Interactivity;
@ -12,6 +13,7 @@ namespace Avalonia.Controls
/// A button with primary and secondary parts that can each be invoked separately.
/// The primary part behaves like a button and the secondary part opens a flyout.
/// </summary>
//[PseudoClasses(":pressed")]
public class SplitButton : ContentControl, ICommandSource
{
/// <summary>
@ -141,109 +143,156 @@ namespace Avalonia.Controls
/// </summary>
private void UpdatePseudoClasses()
{
/*
// place the secondary button
if (m_lastPointerDeviceType == winrt::PointerDeviceType::Touch || m_isKeyDown)
bool internalIsChecked = false;
string pcNormal = ":normal";
string pcDisabled = ":disabled";
string pcSecondaryButtonRight = ":secondaryButtonRight";
string pcSecondaryButtonSpan = ":secondaryButtonSpan";
string pcCheckedFlyoutOpen = ":checkedFlyoutOpen";
string pcFlyoutOpen = ":flyoutOpen";
string pcCheckedTouchPressed = ":checkedTouchPressed";
string pcChecked = ":checked";
string pcCheckedPrimaryPressed = ":checkedPrimaryPressed";
string pcCheckedPrimaryPointerOver = ":checkedPrimaryPointerOver";
string pcCheckedSecondaryPressed = ":checkedSecondaryPressed";
string pcCheckedSecondaryPointerOver = ":checkedSecondaryPointerOver";
string pcTouchPressed = ":touchPressed";
string pcPrimaryPressed = ":primaryPressed";
string pcPrimaryPointerOver = ":primaryPointerOver";
string pcSecondaryPressed = ":secondaryPressed";
string pcSecondaryPointerOver = ":secondaryPointerOver";
// Place the secondary button
// These are mutually exclusive PseudoClasses handled separately from SetExclusivePseudoClass().
// They must be applied in addition to the others.
if (_lastPointerType == PointerType.Touch || _isKeyDown)
{
winrt::VisualStateManager::GoToState(*this, L"SecondaryButtonSpan", useTransitions);
PseudoClasses.Set(pcSecondaryButtonSpan, true);
PseudoClasses.Set(pcSecondaryButtonRight, false);
}
else
{
winrt::VisualStateManager::GoToState(*this, L"SecondaryButtonRight", useTransitions);
PseudoClasses.Set(pcSecondaryButtonSpan, false);
PseudoClasses.Set(pcSecondaryButtonRight, true);
}
// change visual state
auto primaryButton = m_primaryButton.get();
auto secondaryButton = m_secondaryButton.get();
if (!IsEnabled())
// Change the visual state
if (!IsEnabled)
{
winrt::VisualStateManager::GoToState(*this, L"Disabled", useTransitions);
SetExclusivePseudoClass(pcDisabled);
}
else if (primaryButton && secondaryButton)
else if (_primaryButton != null && _secondaryButton != null)
{
if (m_isFlyoutOpen)
if (_isFlyoutOpen)
{
if (InternalIsChecked())
if (internalIsChecked)
{
winrt::VisualStateManager::GoToState(*this, L"CheckedFlyoutOpen", useTransitions);
SetExclusivePseudoClass(pcCheckedFlyoutOpen);
}
else
{
winrt::VisualStateManager::GoToState(*this, L"FlyoutOpen", useTransitions);
SetExclusivePseudoClass(pcFlyoutOpen);
}
}
// SplitButton and ToggleSplitButton share a template -- this section is driving the checked states for ToggleSplitButton.
else if (InternalIsChecked())
else if (internalIsChecked)
{
if (m_lastPointerDeviceType == winrt::PointerDeviceType::Touch || m_isKeyDown)
if (_lastPointerType == PointerType.Touch || _isKeyDown)
{
if (primaryButton.IsPressed() || secondaryButton.IsPressed() || m_isKeyDown)
if (_primaryButton.IsPressed || _secondaryButton.IsPressed || _isKeyDown)
{
winrt::VisualStateManager::GoToState(*this, L"CheckedTouchPressed", useTransitions);
SetExclusivePseudoClass(pcCheckedTouchPressed);
}
else
{
winrt::VisualStateManager::GoToState(*this, L"Checked", useTransitions);
SetExclusivePseudoClass(pcChecked);
}
}
else if (primaryButton.IsPressed())
else if (_primaryButton.IsPressed)
{
winrt::VisualStateManager::GoToState(*this, L"CheckedPrimaryPressed", useTransitions);
SetExclusivePseudoClass(pcCheckedPrimaryPressed);
}
else if (primaryButton.IsPointerOver())
else if (_primaryButton.IsPointerOver)
{
winrt::VisualStateManager::GoToState(*this, L"CheckedPrimaryPointerOver", useTransitions);
SetExclusivePseudoClass(pcCheckedPrimaryPointerOver);
}
else if (secondaryButton.IsPressed())
else if (_secondaryButton.IsPressed)
{
winrt::VisualStateManager::GoToState(*this, L"CheckedSecondaryPressed", useTransitions);
SetExclusivePseudoClass(pcCheckedSecondaryPressed);
}
else if (secondaryButton.IsPointerOver())
else if (_secondaryButton.IsPointerOver)
{
winrt::VisualStateManager::GoToState(*this, L"CheckedSecondaryPointerOver", useTransitions);
SetExclusivePseudoClass(pcCheckedSecondaryPointerOver);
}
else
{
winrt::VisualStateManager::GoToState(*this, L"Checked", useTransitions);
SetExclusivePseudoClass(pcChecked);
}
}
else
{
if (m_lastPointerDeviceType == winrt::PointerDeviceType::Touch || m_isKeyDown)
if (_lastPointerType == PointerType.Touch || _isKeyDown)
{
if (primaryButton.IsPressed() || secondaryButton.IsPressed() || m_isKeyDown)
if (_primaryButton.IsPressed || _secondaryButton.IsPressed || _isKeyDown)
{
winrt::VisualStateManager::GoToState(*this, L"TouchPressed", useTransitions);
SetExclusivePseudoClass(pcTouchPressed);
}
else
{
winrt::VisualStateManager::GoToState(*this, L"Normal", useTransitions);
SetExclusivePseudoClass(pcNormal);
}
}
else if (primaryButton.IsPressed())
else if (_primaryButton.IsPressed)
{
winrt::VisualStateManager::GoToState(*this, L"PrimaryPressed", useTransitions);
SetExclusivePseudoClass(pcPrimaryPressed);
}
else if (primaryButton.IsPointerOver())
else if (_primaryButton.IsPointerOver)
{
winrt::VisualStateManager::GoToState(*this, L"PrimaryPointerOver", useTransitions);
SetExclusivePseudoClass(pcPrimaryPointerOver);
}
else if (secondaryButton.IsPressed())
else if (_secondaryButton.IsPressed)
{
winrt::VisualStateManager::GoToState(*this, L"SecondaryPressed", useTransitions);
SetExclusivePseudoClass(pcSecondaryPressed);
}
else if (secondaryButton.IsPointerOver())
else if (_secondaryButton.IsPointerOver)
{
winrt::VisualStateManager::GoToState(*this, L"SecondaryPointerOver", useTransitions);
SetExclusivePseudoClass(pcSecondaryPointerOver);
}
else
{
winrt::VisualStateManager::GoToState(*this, L"Normal", useTransitions);
SetExclusivePseudoClass(pcNormal);
}
}
}
*/
// Local function to enable the specified PseudoClass and disable all others
// This more closely matches the VisualStateManager of WinUI where the default style originated
void SetExclusivePseudoClass(string pseudoClass = "")
{
PseudoClasses.Set(pcNormal, pseudoClass == pcNormal);
PseudoClasses.Set(pcDisabled, pseudoClass == pcDisabled);
PseudoClasses.Set(pcCheckedFlyoutOpen, pseudoClass == pcCheckedFlyoutOpen);
PseudoClasses.Set(pcFlyoutOpen, pseudoClass == pcFlyoutOpen);
PseudoClasses.Set(pcCheckedTouchPressed, pseudoClass == pcCheckedTouchPressed);
PseudoClasses.Set(pcChecked, pseudoClass == pcChecked);
PseudoClasses.Set(pcCheckedPrimaryPressed, pseudoClass == pcCheckedPrimaryPressed);
PseudoClasses.Set(pcCheckedPrimaryPointerOver, pseudoClass == pcCheckedPrimaryPointerOver);
PseudoClasses.Set(pcCheckedSecondaryPressed, pseudoClass == pcCheckedSecondaryPressed);
PseudoClasses.Set(pcCheckedSecondaryPointerOver, pseudoClass == pcCheckedSecondaryPointerOver);
PseudoClasses.Set(pcTouchPressed, pseudoClass == pcTouchPressed);
PseudoClasses.Set(pcPrimaryPressed, pseudoClass == pcPrimaryPressed);
PseudoClasses.Set(pcPrimaryPointerOver, pseudoClass == pcPrimaryPointerOver);
PseudoClasses.Set(pcSecondaryPressed, pseudoClass == pcSecondaryPressed);
PseudoClasses.Set(pcSecondaryPointerOver, pseudoClass == pcSecondaryPointerOver);
}
}
/// <summary>
@ -342,8 +391,8 @@ namespace Avalonia.Controls
UnregisterEvents();
UnregisterFlyoutEvents(Flyout);
_primaryButton = e.NameScope.Find<Button>("PrimaryButton");
_secondaryButton = e.NameScope.Find<Button>("SecondaryButton");
_primaryButton = e.NameScope.Find<Button>("PART_PrimaryButton");
_secondaryButton = e.NameScope.Find<Button>("PART_SecondaryButton");
_buttonPropertyChangedDisposable = new CompositeDisposable();

27
src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml

@ -556,6 +556,33 @@
<Thickness x:Key="TreeViewItemBorderThemeThickness">1</Thickness>
<x:Double x:Key="TreeViewItemMinHeight">32</x:Double>
<!-- Resources for SplitButton.xaml -->
<StaticResource x:Key="SplitButtonBackground" ResourceKey="SystemControlBackgroundBaseLowBrush" />
<SolidColorBrush x:Key="SplitButtonBackgroundPointerOver" Color="{StaticResource SystemBaseHighColor}" Opacity="0.1" />
<StaticResource x:Key="SplitButtonBackgroundPressed" ResourceKey="SystemControlBackgroundBaseMediumLowBrush" />
<StaticResource x:Key="SplitButtonBackgroundDisabled" ResourceKey="SystemControlBackgroundBaseLowBrush" />
<StaticResource x:Key="SplitButtonBackgroundChecked" ResourceKey="SystemControlHighlightAccentBrush" />
<StaticResource x:Key="SplitButtonBackgroundCheckedPointerOver" ResourceKey="SystemAccentColorDark1" />
<StaticResource x:Key="SplitButtonBackgroundCheckedPressed" ResourceKey="SystemAccentColorLight1" />
<StaticResource x:Key="SplitButtonBackgroundCheckedDisabled" ResourceKey="SystemControlBackgroundBaseLowBrush" />
<StaticResource x:Key="SplitButtonForeground" ResourceKey="SystemControlForegroundBaseHighBrush" />
<StaticResource x:Key="SplitButtonForegroundPointerOver" ResourceKey="SystemControlHighlightBaseHighBrush" />
<StaticResource x:Key="SplitButtonForegroundPressed" ResourceKey="SystemControlHighlightBaseHighBrush" />
<StaticResource x:Key="SplitButtonForegroundDisabled" ResourceKey="SystemControlDisabledBaseMediumLowBrush" />
<StaticResource x:Key="SplitButtonForegroundChecked" ResourceKey="SystemControlHighlightAltChromeWhiteBrush" />
<StaticResource x:Key="SplitButtonForegroundCheckedPointerOver" ResourceKey="SystemControlHighlightAltChromeWhiteBrush" />
<StaticResource x:Key="SplitButtonForegroundCheckedPressed" ResourceKey="SystemControlHighlightAltChromeWhiteBrush" />
<StaticResource x:Key="SplitButtonForegroundCheckedDisabled" ResourceKey="SystemControlDisabledBaseMediumLowBrush" />
<StaticResource x:Key="SplitButtonBorderBrush" ResourceKey="SystemControlForegroundTransparentBrush" />
<StaticResource x:Key="SplitButtonBorderBrushPointerOver" ResourceKey="SystemControlForegroundTransparentBrush" />
<StaticResource x:Key="SplitButtonBorderBrushPressed" ResourceKey="SystemControlHighlightTransparentBrush" />
<StaticResource x:Key="SplitButtonBorderBrushDisabled" ResourceKey="SystemControlDisabledTransparentBrush" />
<StaticResource x:Key="SplitButtonBorderBrushChecked" ResourceKey="SystemControlHighlightAltTransparentBrush" />
<StaticResource x:Key="SplitButtonBorderBrushCheckedPointerOver" ResourceKey="SystemControlHighlightAltTransparentBrush" />
<StaticResource x:Key="SplitButtonBorderBrushCheckedPressed" ResourceKey="SystemControlHighlightAltTransparentBrush" />
<StaticResource x:Key="SplitButtonBorderBrushCheckedDisabled" ResourceKey="SystemControlDisabledTransparentBrush" />
<Thickness x:Key="SplitButtonBorderThemeThickness">1</Thickness>
<!-- Resources for SplitView.xaml -->
<StaticResource x:Key="SplitViewLightDismissOverlayBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" />

27
src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml

@ -550,6 +550,33 @@
<Thickness x:Key="TreeViewItemBorderThemeThickness">1</Thickness>
<x:Double x:Key="TreeViewItemMinHeight">32</x:Double>
<!-- Resources for SplitButton.xaml -->
<StaticResource x:Key="SplitButtonBackground" ResourceKey="SystemControlBackgroundBaseLowBrush" />
<SolidColorBrush x:Key="SplitButtonBackgroundPointerOver" Color="{StaticResource SystemBaseHighColor}" Opacity="0.1" />
<StaticResource x:Key="SplitButtonBackgroundPressed" ResourceKey="SystemControlBackgroundBaseMediumLowBrush" />
<StaticResource x:Key="SplitButtonBackgroundDisabled" ResourceKey="SystemControlBackgroundBaseLowBrush" />
<StaticResource x:Key="SplitButtonBackgroundChecked" ResourceKey="SystemControlHighlightAccentBrush" />
<StaticResource x:Key="SplitButtonBackgroundCheckedPointerOver" ResourceKey="SystemAccentColorLight1" />
<StaticResource x:Key="SplitButtonBackgroundCheckedPressed" ResourceKey="SystemAccentColorDark1" />
<StaticResource x:Key="SplitButtonBackgroundCheckedDisabled" ResourceKey="SystemControlBackgroundBaseLowBrush" />
<StaticResource x:Key="SplitButtonForeground" ResourceKey="SystemControlForegroundBaseHighBrush" />
<StaticResource x:Key="SplitButtonForegroundPointerOver" ResourceKey="SystemControlHighlightBaseHighBrush" />
<StaticResource x:Key="SplitButtonForegroundPressed" ResourceKey="SystemControlHighlightBaseHighBrush" />
<StaticResource x:Key="SplitButtonForegroundDisabled" ResourceKey="SystemControlDisabledBaseMediumLowBrush" />
<StaticResource x:Key="SplitButtonForegroundChecked" ResourceKey="SystemControlHighlightAltChromeWhiteBrush" />
<StaticResource x:Key="SplitButtonForegroundCheckedPointerOver" ResourceKey="SystemControlHighlightAltChromeWhiteBrush" />
<StaticResource x:Key="SplitButtonForegroundCheckedPressed" ResourceKey="SystemControlHighlightAltChromeWhiteBrush" />
<StaticResource x:Key="SplitButtonForegroundCheckedDisabled" ResourceKey="SystemControlDisabledBaseMediumLowBrush" />
<StaticResource x:Key="SplitButtonBorderBrush" ResourceKey="SystemControlForegroundTransparentBrush" />
<StaticResource x:Key="SplitButtonBorderBrushPointerOver" ResourceKey="SystemControlForegroundTransparentBrush" />
<StaticResource x:Key="SplitButtonBorderBrushPressed" ResourceKey="SystemControlHighlightTransparentBrush" />
<StaticResource x:Key="SplitButtonBorderBrushDisabled" ResourceKey="SystemControlDisabledTransparentBrush" />
<StaticResource x:Key="SplitButtonBorderBrushChecked" ResourceKey="SystemControlHighlightAltTransparentBrush" />
<StaticResource x:Key="SplitButtonBorderBrushCheckedPointerOver" ResourceKey="SystemControlHighlightAltTransparentBrush" />
<StaticResource x:Key="SplitButtonBorderBrushCheckedPressed" ResourceKey="SystemControlHighlightAltTransparentBrush" />
<StaticResource x:Key="SplitButtonBorderBrushCheckedDisabled" ResourceKey="SystemControlDisabledTransparentBrush" />
<Thickness x:Key="SplitButtonBorderThemeThickness">1</Thickness>
<!-- Resources for SplitView.xaml -->
<StaticResource x:Key="SplitViewLightDismissOverlayBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" />

1
src/Avalonia.Themes.Fluent/Controls/FluentControls.xaml

@ -56,6 +56,7 @@
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/NotificationCard.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/NativeMenuBar.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ToggleSwitch.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/SplitButton.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/SplitView.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/DatePicker.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/TimePicker.xaml"/>

370
src/Avalonia.Themes.Fluent/Controls/SplitButton.xaml

@ -0,0 +1,370 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:CompileBindings="True">
<Design.PreviewWith>
</Design.PreviewWith>
<Styles.Resources>
<x:Double x:Key="SplitButtonPrimaryButtonSize">32</x:Double>
<x:Double x:Key="SplitButtonSecondaryButtonSize">32</x:Double>
</Styles.Resources>
<Style Selector="SplitButton">
<Setter Property="Background" Value="{DynamicResource SplitButtonBackground}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForeground}" />
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource SplitButtonBorderThemeThickness}" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<!--<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
<Setter Property="UseSystemFocusVisuals" Value="True" />
<Setter Property="FocusVisualMargin" Value="-3" />-->
<Setter Property="KeyboardNavigation.IsTabStop" Value="True" />
<Setter Property="Padding" Value="{DynamicResource ButtonPadding}" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<!-- A Border was added here since Avalonia does not support Background/Border/CornerRadius on Grid directly -->
<!-- ClipToBounds added as a temporary work-around for: https://github.com/AvaloniaUI/Avalonia/issues/2105 -->
<Border Background="Transparent"
CornerRadius="{TemplateBinding CornerRadius}"
ClipToBounds="True">
<Border.Styles>
<!-- Override the style of the inner buttons so that they don't affect background/foreground/border colors -->
<Style Selector="Button">
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForeground}" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="{DynamicResource SplitButtonBorderThemeThickness}" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<!--<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}" />
<Setter Property="FocusVisualMargin" Value="-3" />-->
<Setter Property="Template">
<ControlTemplate>
<!-- Switched from Grid to Border to optimize and support Foreground/Background properties -->
<Border x:Name="RootBorder"
Background="Transparent">
<ContentPresenter x:Name="ContentPresenter"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
</ControlTemplate>
</Setter>
</Style>
<Style Selector="Button:disabled">
<Setter Property="Background" Value="{DynamicResource SplitButtonBackgroundDisabled}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundDisabled}" />
</Style>
</Border.Styles>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"
MinWidth="{DynamicResource SplitButtonPrimaryButtonSize}" />
<ColumnDefinition Width="1" />
<ColumnDefinition Width="{DynamicResource SplitButtonSecondaryButtonSize}" />
</Grid.ColumnDefinitions>
<!-- Changed from Grid to Rectangle since Avalonia does not support Background on Grid directly -->
<Rectangle x:Name="PrimaryBackgroundRectangle"
Fill="{TemplateBinding Background}" />
<Rectangle x:Name="SecondaryBackgroundRectangle"
Fill="{TemplateBinding Background}"
Grid.Column="2" />
<!-- Changed from Grid to Border to support Background/Border/CornerRadius properties -->
<Border x:Name="Border"
Grid.ColumnSpan="3"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}" />
<Button x:Name="PART_PrimaryButton"
Grid.Column="0"
Foreground="{TemplateBinding Foreground}"
Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="Transparent"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Command="{TemplateBinding Command}"
CommandParameter="{TemplateBinding CommandParameter}"
FontFamily="{TemplateBinding FontFamily}"
FontSize="{TemplateBinding FontSize}"
FontWeight="{TemplateBinding FontWeight}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Padding="{TemplateBinding Padding}"
KeyboardNavigation.IsTabStop="False" />
<Button x:Name="PART_SecondaryButton"
Grid.Column="2"
Foreground="{TemplateBinding Foreground}"
Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="Transparent"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
KeyboardNavigation.IsTabStop="False">
<Button.Content>
<!-- TextBlock converted to a Path and placed within Viewbox -->
<Viewbox UseLayoutRounding="False"
IsHitTestVisible="False"
Height="12"
Width="12">
<Path x:Name="DropDownGlyphPath"
VerticalAlignment="Center"
HorizontalAlignment="Right"
Fill="{TemplateBinding Foreground}"
Data="M1939 486L2029 576L1024 1581L19 576L109 486L1024 1401L1939 486Z"
Stretch="Uniform" />
</Viewbox>
</Button.Content>
</Button>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- Disabled State -->
<Style Selector="SplitButton:disabled /template/ Border#Border">
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrushDisabled}" />
</Style>
<Style Selector="SplitButton:disabled /template/ Path#DropDownGlyphPath">
<Setter Property="Fill" Value="{DynamicResource SplitButtonForegroundDisabled}" />
</Style>
<!-- FlyoutOpen State -->
<Style Selector="SplitButton:flyoutOpen /template/ Rectangle#PrimaryBackgroundRectangle">
<Setter Property="Fill" Value="{DynamicResource SplitButtonBackgroundPressed}" />
</Style>
<Style Selector="SplitButton:flyoutOpen /template/ Rectangle#SecondaryBackgroundRectangle">
<Setter Property="Fill" Value="{DynamicResource SplitButtonBackgroundPressed}" />
</Style>
<Style Selector="SplitButton:flyoutOpen /template/ Border#Border">
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrushPressed}" />
</Style>
<Style Selector="SplitButton:flyoutOpen /template/ Button#PrimaryButton">
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<Style Selector="SplitButton:flyoutOpen /template/ Button#SecondaryButton">
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<!-- TouchPressed State -->
<Style Selector="SplitButton:touchPressed /template/ Rectangle#PrimaryBackgroundRectangle">
<Setter Property="Fill" Value="{DynamicResource SplitButtonBackgroundPressed}" />
</Style>
<Style Selector="SplitButton:touchPressed /template/ Rectangle#SecondaryBackgroundRectangle">
<Setter Property="Fill" Value="{DynamicResource SplitButtonBackgroundPressed}" />
</Style>
<Style Selector="SplitButton:touchPressed /template/ Border#Border">
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrushPressed}" />
</Style>
<Style Selector="SplitButton:touchPressed /template/ Button#PrimaryButton">
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<Style Selector="SplitButton:touchPressed /template/ Button#SecondaryButton">
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<!-- PrimaryPointerOver State -->
<Style Selector="SplitButton:primaryPointerOver /template/ Rectangle#PrimaryBackgroundRectangle">
<Setter Property="Fill" Value="{DynamicResource SplitButtonBackgroundPointerOver}" />
</Style>
<Style Selector="SplitButton:primaryPointerOver /template/ Button#PrimaryButton">
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrushPointerOver}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPointerOver}" />
</Style>
<Style Selector="SplitButton:primaryPointerOver /template/ Rectangle#SecondaryBackgroundRectangle">
<Setter Property="Fill" Value="{DynamicResource SplitButtonBackground}" />
</Style>
<!-- PrimaryPressed State -->
<Style Selector="SplitButton:primaryPressed /template/ Rectangle#PrimaryBackgroundRectangle">
<Setter Property="Fill" Value="{DynamicResource SplitButtonBackgroundPressed}" />
</Style>
<Style Selector="SplitButton:primaryPressed /template/ Button#PrimaryButton">
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrushPressed}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<Style Selector="SplitButton:primaryPressed /template/ Rectangle#SecondaryBackgroundRectangle">
<Setter Property="Fill" Value="{DynamicResource SplitButtonBackground}" />
</Style>
<!-- SecondaryPointerOver State -->
<Style Selector="SplitButton:secondaryPointerOver /template/ Rectangle#PrimaryBackgroundRectangle">
<Setter Property="Fill" Value="{DynamicResource SplitButtonBackground}" />
</Style>
<Style Selector="SplitButton:secondaryPointerOver /template/ Rectangle#SecondaryBackgroundRectangle">
<Setter Property="Fill" Value="{DynamicResource SplitButtonBackgroundPointerOver}" />
</Style>
<Style Selector="SplitButton:secondaryPointerOver /template/ Button#SecondaryButton">
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrushPointerOver}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPointerOver}" />
</Style>
<!-- SecondaryPressed State -->
<Style Selector="SplitButton:secondaryPressed /template/ Rectangle#PrimaryBackgroundRectangle">
<Setter Property="Fill" Value="{DynamicResource SplitButtonBackground}" />
</Style>
<Style Selector="SplitButton:secondaryPressed /template/ Rectangle#SecondaryBackgroundRectangle">
<Setter Property="Fill" Value="{DynamicResource SplitButtonBackgroundPressed}" />
</Style>
<Style Selector="SplitButton:secondaryPressed /template/ Button#SecondaryButton">
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrushPressed}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<!-- Checked State -->
<!--<VisualState x:Name="Checked">
<VisualState.Setters>
<Setter Target="PrimaryBackgroundRectangle.Fill"
Value="{DynamicResource SplitButtonBackgroundChecked}" />
<Setter Target="SecondaryBackgroundRectangle.Fill"
Value="{DynamicResource SplitButtonBackgroundChecked}" />
<Setter Target="Border.BorderBrush"
Value="{DynamicResource SplitButtonBorderBrushChecked}" />
<Setter Target="PrimaryButton.Foreground"
Value="{DynamicResource SplitButtonForegroundChecked}" />
<Setter Target="SecondaryButton.Foreground"
Value="{DynamicResource SplitButtonForegroundChecked}" />
</VisualState.Setters>
</VisualState>-->
<!-- CheckedFlyoutOpen State -->
<!--<VisualState x:Name="CheckedFlyoutOpen">
<VisualState.Setters>
<Setter Target="PrimaryBackgroundRectangle.Fill"
Value="{DynamicResource SplitButtonBackgroundCheckedPressed}" />
<Setter Target="SecondaryBackgroundRectangle.Fill"
Value="{DynamicResource SplitButtonBackgroundCheckedPressed}" />
<Setter Target="Border.BorderBrush"
Value="{DynamicResource SplitButtonBorderBrushCheckedPressed}" />
<Setter Target="PrimaryButton.Foreground"
Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
<Setter Target="SecondaryButton.Foreground"
Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</VisualState.Setters>
</VisualState>-->
<!-- CheckedTouchPressed State -->
<!--<VisualState x:Name="CheckedTouchPressed">
<VisualState.Setters>
<Setter Target="PrimaryBackgroundRectangle.Fill"
Value="{DynamicResource SplitButtonBackgroundCheckedPressed}" />
<Setter Target="SecondaryBackgroundRectangle.Fill"
Value="{DynamicResource SplitButtonBackgroundCheckedPressed}" />
<Setter Target="Border.BorderBrush"
Value="{DynamicResource SplitButtonBorderBrushCheckedPressed}" />
<Setter Target="PrimaryButton.Foreground"
Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
<Setter Target="SecondaryButton.Foreground"
Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</VisualState.Setters>
</VisualState>-->
<!-- CheckedPrimaryPointerOver State -->
<!--<VisualState x:Name="CheckedPrimaryPointerOver">
<VisualState.Setters>
<Setter Target="Border.BorderBrush"
Value="{DynamicResource SplitButtonBorderBrushChecked}" />
<Setter Target="PrimaryBackgroundRectangle.Fill"
Value="{DynamicResource SplitButtonBackgroundCheckedPointerOver}" />
<Setter Target="PrimaryButton.BorderBrush"
Value="{DynamicResource SplitButtonBorderBrushCheckedPointerOver}" />
<Setter Target="PrimaryButton.Foreground"
Value="{DynamicResource SplitButtonForegroundCheckedPointerOver}" />
<Setter Target="SecondaryBackgroundRectangle.Fill"
Value="{DynamicResource SplitButtonBackgroundChecked}" />
<Setter Target="SecondaryButton.Foreground"
Value="{DynamicResource SplitButtonForegroundChecked}" />
</VisualState.Setters>
</VisualState>-->
<!-- CheckedPrimaryPressed State -->
<!--<VisualState x:Name="CheckedPrimaryPressed">
<VisualState.Setters>
<Setter Target="Border.BorderBrush"
Value="{DynamicResource SplitButtonBorderBrushChecked}" />
<Setter Target="PrimaryBackgroundRectangle.Fill"
Value="{DynamicResource SplitButtonBackgroundCheckedPressed}" />
<Setter Target="PrimaryButton.BorderBrush"
Value="{DynamicResource SplitButtonBorderBrushCheckedPressed}" />
<Setter Target="PrimaryButton.Foreground"
Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
<Setter Target="SecondaryBackgroundRectangle.Fill"
Value="{DynamicResource SplitButtonBackgroundChecked}" />
<Setter Target="SecondaryButton.Foreground"
Value="{DynamicResource SplitButtonForegroundChecked}" />
</VisualState.Setters>
</VisualState>-->
<!-- CheckedSecondaryPointerOver State -->
<!--<VisualState x:Name="CheckedSecondaryPointerOver">
<VisualState.Setters>
<Setter Target="Border.BorderBrush"
Value="{DynamicResource SplitButtonBorderBrushChecked}" />
<Setter Target="PrimaryBackgroundRectangle.Fill"
Value="{DynamicResource SplitButtonBackgroundChecked}" />
<Setter Target="PrimaryButton.Foreground"
Value="{DynamicResource SplitButtonForegroundChecked}" />
<Setter Target="SecondaryBackgroundRectangle.Fill"
Value="{DynamicResource SplitButtonBackgroundCheckedPointerOver}" />
<Setter Target="SecondaryButton.BorderBrush"
Value="{DynamicResource SplitButtonBorderBrushCheckedPointerOver}" />
<Setter Target="SecondaryButton.Foreground"
Value="{DynamicResource SplitButtonForegroundCheckedPointerOver}" />
</VisualState.Setters>
</VisualState>-->
<!-- CheckedSecondaryPressed State -->
<!--<VisualState x:Name="CheckedSecondaryPressed">
<VisualState.Setters>
<Setter Target="Border.BorderBrush"
Value="{DynamicResource SplitButtonBorderBrushChecked}" />
<Setter Target="PrimaryBackgroundRectangle.Fill"
Value="{DynamicResource SplitButtonBackgroundChecked}" />
<Setter Target="PrimaryButton.Foreground"
Value="{DynamicResource SplitButtonForegroundChecked}" />
<Setter Target="SecondaryBackgroundRectangle.Fill"
Value="{DynamicResource SplitButtonBackgroundCheckedPressed}" />
<Setter Target="SecondaryButton.BorderBrush"
Value="{DynamicResource SplitButtonBorderBrushCheckedPressed}" />
<Setter Target="SecondaryButton.Foreground"
Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</VisualState.Setters>
</VisualState>-->
<!--VisualStateGroup x:Name="SecondaryButtonPlacementStates">
<VisualState x:Name="SecondaryButtonRight" />
<VisualState x:Name="SecondaryButtonSpan">
<VisualState.Setters>
<Setter Target="SecondaryButton.(Grid.Column)"
Value="0" />
<Setter Target="SecondaryButton.(Grid.ColumnSpan)"
Value="3" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup-->
</Styles>
Loading…
Cancel
Save