Browse Source

Merge

pull/8471/head
Benedikt Stebner 4 years ago
parent
commit
811ee7b3c8
  1. 4
      samples/BindingDemo/App.xaml
  2. 2
      samples/BindingDemo/BindingDemo.csproj
  3. 1
      samples/ControlCatalog.Android/ControlCatalog.Android.csproj
  4. 8
      samples/ControlCatalog/App.xaml
  5. 15
      samples/ControlCatalog/Pages/ExpanderPage.xaml
  6. 2
      samples/ControlCatalog/Pages/ExpanderPage.xaml.cs
  7. 44
      samples/ControlCatalog/Pages/OpenGlPage.xaml.cs
  8. 27
      samples/ControlCatalog/ViewModels/ExpanderPageViewModel.cs
  9. 8
      samples/RenderDemo/App.xaml
  10. 286
      samples/SampleControls/HamburgerMenu/HamburgerMenu.xaml
  11. 5
      src/Avalonia.Base/Input/Cursor.cs
  12. 18
      src/Avalonia.Base/Input/DragEventArgs.cs
  13. 11
      src/Avalonia.Base/Input/GotFocusEventArgs.cs
  14. 5
      src/Avalonia.Base/Input/IInputRoot.cs
  15. 13
      src/Avalonia.Base/Input/IKeyboardDevice.cs
  16. 12
      src/Avalonia.Base/Input/IMouseDevice.cs
  17. 14
      src/Avalonia.Base/Input/IPointerDevice.cs
  18. 2
      src/Avalonia.Base/Input/KeyEventArgs.cs
  19. 12
      src/Avalonia.Base/Input/KeyGesture.cs
  20. 54
      src/Avalonia.Base/Input/MouseDevice.cs
  21. 19
      src/Avalonia.Base/Input/PenDevice.cs
  22. 62
      src/Avalonia.Base/Input/PointerEventArgs.cs
  23. 2
      src/Avalonia.Base/Input/PointerOverPreProcessor.cs
  24. 5
      src/Avalonia.Base/Input/Raw/RawDragEvent.cs
  25. 3
      src/Avalonia.Base/Input/Raw/RawTouchEventArgs.cs
  26. 11
      src/Avalonia.Base/Input/TouchDevice.cs
  27. 5
      src/Avalonia.Base/StyledElement.cs
  28. 3
      src/Avalonia.Build.Tasks/Avalonia.Build.Tasks.csproj
  29. 3
      src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs
  30. 27
      src/Avalonia.Controls/Chrome/CaptionButtons.cs
  31. 8
      src/Avalonia.Controls/Chrome/TitleBar.cs
  32. 2
      src/Avalonia.Controls/DateTimePickers/DateTimePickerPanel.cs
  33. 9
      src/Avalonia.Controls/Platform/ITopLevelImpl.cs
  34. 11
      src/Avalonia.Controls/Primitives/PopupPositioning/IPopupPositioner.cs
  35. 1
      src/Avalonia.Controls/Remote/Server/RemoteServerTopLevelImpl.cs
  36. 5
      src/Avalonia.Controls/TopLevel.cs
  37. 11
      src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml.cs
  38. 4
      src/Avalonia.OpenGL/Angle/AngleWin32EglDisplay.cs
  39. 1
      src/Avalonia.OpenGL/Avalonia.OpenGL.csproj
  40. 14
      src/Avalonia.OpenGL/Controls/OpenGlControlBase.cs
  41. 376
      src/Avalonia.OpenGL/Egl/EglConsts.cs
  42. 2
      src/Avalonia.OpenGL/Egl/EglContext.cs
  43. 4
      src/Avalonia.OpenGL/Egl/EglDisplay.cs
  44. 225
      src/Avalonia.OpenGL/Egl/EglInterface.cs
  45. 44
      src/Avalonia.OpenGL/GlBasicInfoInterface.cs
  46. 10783
      src/Avalonia.OpenGL/GlConsts.cs
  47. 103
      src/Avalonia.OpenGL/GlEntryPointAttribute.cs
  48. 494
      src/Avalonia.OpenGL/GlInterface.cs
  49. 79
      src/Avalonia.OpenGL/GlInterfaceBase.cs
  50. 1
      src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml
  51. 1
      src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml
  52. 110
      src/Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml
  53. 43
      src/Avalonia.Themes.Fluent/Controls/Button.xaml
  54. 184
      src/Avalonia.Themes.Fluent/Controls/ButtonSpinner.xaml
  55. 42
      src/Avalonia.Themes.Fluent/Controls/Calendar.xaml
  56. 182
      src/Avalonia.Themes.Fluent/Controls/CalendarButton.xaml
  57. 236
      src/Avalonia.Themes.Fluent/Controls/CalendarDatePicker.xaml
  58. 172
      src/Avalonia.Themes.Fluent/Controls/CalendarDayButton.xaml
  59. 170
      src/Avalonia.Themes.Fluent/Controls/CalendarItem.xaml
  60. 141
      src/Avalonia.Themes.Fluent/Controls/CaptionButtons.xaml
  61. 37
      src/Avalonia.Themes.Fluent/Controls/Carousel.xaml
  62. 451
      src/Avalonia.Themes.Fluent/Controls/CheckBox.xaml
  63. 200
      src/Avalonia.Themes.Fluent/Controls/ComboBox.xaml
  64. 106
      src/Avalonia.Themes.Fluent/Controls/ComboBoxItem.xaml
  65. 6
      src/Avalonia.Themes.Fluent/Controls/Common.xaml
  66. 35
      src/Avalonia.Themes.Fluent/Controls/ContentControl.xaml
  67. 84
      src/Avalonia.Themes.Fluent/Controls/ContextMenu.xaml
  68. 21
      src/Avalonia.Themes.Fluent/Controls/DataValidationErrors.xaml
  69. 332
      src/Avalonia.Themes.Fluent/Controls/DatePicker.xaml
  70. 118
      src/Avalonia.Themes.Fluent/Controls/DateTimePickerShared.xaml
  71. 192
      src/Avalonia.Themes.Fluent/Controls/DropDownButton.xaml
  72. 41
      src/Avalonia.Themes.Fluent/Controls/EmbeddableControlRoot.xaml
  73. 371
      src/Avalonia.Themes.Fluent/Controls/Expander.xaml
  74. 147
      src/Avalonia.Themes.Fluent/Controls/FluentControls.xaml
  75. 14
      src/Avalonia.Themes.Fluent/Controls/FlyoutPresenter.xaml
  76. 2
      src/Avalonia.Themes.Fluent/Controls/FocusAdorner.xaml
  77. 46
      src/Avalonia.Themes.Fluent/Controls/GridSplitter.xaml
  78. 35
      src/Avalonia.Themes.Fluent/Controls/ItemsControl.xaml
  79. 40
      src/Avalonia.Themes.Fluent/Controls/Label.xaml
  80. 18
      src/Avalonia.Themes.Fluent/Controls/ListBox.xaml
  81. 101
      src/Avalonia.Themes.Fluent/Controls/ListBoxItem.xaml
  82. 604
      src/Avalonia.Themes.Fluent/Controls/ManagedFileChooser.xaml
  83. 133
      src/Avalonia.Themes.Fluent/Controls/Menu.xaml
  84. 10
      src/Avalonia.Themes.Fluent/Controls/MenuFlyoutPresenter.xaml
  85. 322
      src/Avalonia.Themes.Fluent/Controls/MenuItem.xaml
  86. 98
      src/Avalonia.Themes.Fluent/Controls/MenuScrollViewer.xaml
  87. 61
      src/Avalonia.Themes.Fluent/Controls/NativeMenuBar.xaml
  88. 107
      src/Avalonia.Themes.Fluent/Controls/NotificationCard.xaml
  89. 15
      src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml
  90. 43
      src/Avalonia.Themes.Fluent/Controls/OverlayPopupHost.xaml
  91. 18
      src/Avalonia.Themes.Fluent/Controls/PathIcon.xaml
  92. 24
      src/Avalonia.Themes.Fluent/Controls/PopupRoot.xaml
  93. 322
      src/Avalonia.Themes.Fluent/Controls/ProgressBar.xaml
  94. 286
      src/Avalonia.Themes.Fluent/Controls/RadioButton.xaml
  95. 59
      src/Avalonia.Themes.Fluent/Controls/RepeatButton.xaml
  96. 521
      src/Avalonia.Themes.Fluent/Controls/ScrollBar.xaml
  97. 152
      src/Avalonia.Themes.Fluent/Controls/ScrollViewer.xaml
  98. 19
      src/Avalonia.Themes.Fluent/Controls/Separator.xaml
  99. 606
      src/Avalonia.Themes.Fluent/Controls/Slider.xaml
  100. 389
      src/Avalonia.Themes.Fluent/Controls/SplitButton.xaml

4
samples/BindingDemo/App.xaml

@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="BindingDemo.App"> x:Class="BindingDemo.App">
<Application.Styles> <Application.Styles>
<StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml"/> <FluentTheme />
<StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml"/>
</Application.Styles> </Application.Styles>
</Application> </Application>

2
samples/BindingDemo/BindingDemo.csproj

@ -5,7 +5,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" /> <ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" />
<ProjectReference Include="..\..\src\Avalonia.Themes.Default\Avalonia.Themes.Default.csproj" /> <ProjectReference Include="..\..\src\Avalonia.Themes.Fluent\Avalonia.Themes.Fluent.csproj" />
<ProjectReference Include="..\..\src\Linux\Avalonia.LinuxFramebuffer\Avalonia.LinuxFramebuffer.csproj" /> <ProjectReference Include="..\..\src\Linux\Avalonia.LinuxFramebuffer\Avalonia.LinuxFramebuffer.csproj" />
<ProjectReference Include="..\MiniMvvm\MiniMvvm.csproj" /> <ProjectReference Include="..\MiniMvvm\MiniMvvm.csproj" />
</ItemGroup> </ItemGroup>

1
samples/ControlCatalog.Android/ControlCatalog.Android.csproj

@ -9,7 +9,6 @@
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<AndroidPackageFormat>apk</AndroidPackageFormat> <AndroidPackageFormat>apk</AndroidPackageFormat>
<MSBuildEnableWorkloadResolver>true</MSBuildEnableWorkloadResolver> <MSBuildEnableWorkloadResolver>true</MSBuildEnableWorkloadResolver>
<RuntimeIdentifiers>android-arm64;android-x64</RuntimeIdentifiers>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<AndroidResource Include="..\..\build\Assets\Icon.png"> <AndroidResource Include="..\..\build\Assets\Icon.png">

8
samples/ControlCatalog/App.xaml

@ -5,6 +5,13 @@
x:CompileBindings="True" x:CompileBindings="True"
Name="Avalonia ControlCatalog" Name="Avalonia ControlCatalog"
x:Class="ControlCatalog.App"> x:Class="ControlCatalog.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceInclude Source="avares://ControlSamples/HamburgerMenu/HamburgerMenu.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
<Application.Styles> <Application.Styles>
<Style Selector="TextBlock.h1, TextBlock.h2, TextBlock.h3"> <Style Selector="TextBlock.h1, TextBlock.h2, TextBlock.h3">
<Setter Property="TextWrapping" Value="Wrap" /> <Setter Property="TextWrapping" Value="Wrap" />
@ -29,7 +36,6 @@
<Style Selector="Label.h3"> <Style Selector="Label.h3">
<Setter Property="FontSize" Value="12" /> <Setter Property="FontSize" Value="12" />
</Style> </Style>
<StyleInclude Source="avares://ControlSamples/HamburgerMenu/HamburgerMenu.xaml" />
</Application.Styles> </Application.Styles>
<TrayIcon.Icons> <TrayIcon.Icons>
<TrayIcons> <TrayIcons>

15
samples/ControlCatalog/Pages/ExpanderPage.xaml

@ -8,26 +8,31 @@
Margin="0,16,0,0" Margin="0,16,0,0"
HorizontalAlignment="Center" HorizontalAlignment="Center"
Spacing="16"> Spacing="16">
<Expander Header="Expand Up" ExpandDirection="Up"> <Expander Header="Expand Up" ExpandDirection="Up"
CornerRadius="{Binding CornerRadius}">
<StackPanel> <StackPanel>
<TextBlock>Expanded content</TextBlock> <TextBlock>Expanded content</TextBlock>
</StackPanel> </StackPanel>
</Expander> </Expander>
<Expander Header="Expand Down" ExpandDirection="Down"> <Expander Header="Expand Down" ExpandDirection="Down"
CornerRadius="{Binding CornerRadius}">
<StackPanel> <StackPanel>
<TextBlock>Expanded content</TextBlock> <TextBlock>Expanded content</TextBlock>
</StackPanel> </StackPanel>
</Expander> </Expander>
<Expander Header="Expand Left" ExpandDirection="Left"> <Expander Header="Expand Left" ExpandDirection="Left"
CornerRadius="{Binding CornerRadius}">
<StackPanel> <StackPanel>
<TextBlock>Expanded content</TextBlock> <TextBlock>Expanded content</TextBlock>
</StackPanel> </StackPanel>
</Expander> </Expander>
<Expander Header="Expand Right" ExpandDirection="Right"> <Expander Header="Expand Right" ExpandDirection="Right"
CornerRadius="{Binding CornerRadius}">
<StackPanel> <StackPanel>
<TextBlock>Expanded content</TextBlock> <TextBlock>Expanded content</TextBlock>
</StackPanel> </StackPanel>
</Expander> </Expander>
</StackPanel> <CheckBox IsChecked="{Binding Rounded}">Rounded</CheckBox>
</StackPanel>
</StackPanel> </StackPanel>
</UserControl> </UserControl>

2
samples/ControlCatalog/Pages/ExpanderPage.xaml.cs

@ -1,5 +1,6 @@
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using ControlCatalog.ViewModels;
namespace ControlCatalog.Pages namespace ControlCatalog.Pages
{ {
@ -8,6 +9,7 @@ namespace ControlCatalog.Pages
public ExpanderPage() public ExpanderPage()
{ {
this.InitializeComponent(); this.InitializeComponent();
DataContext = new ExpanderPageViewModel();
} }
private void InitializeComponent() private void InitializeComponent()

44
samples/ControlCatalog/Pages/OpenGlPage.xaml.cs

@ -90,7 +90,6 @@ namespace ControlCatalog.Pages
private int _vertexBufferObject; private int _vertexBufferObject;
private int _indexBufferObject; private int _indexBufferObject;
private int _vertexArrayObject; private int _vertexArrayObject;
private GlExtrasInterface _glExt;
private string GetShader(bool fragment, string shader) private string GetShader(bool fragment, string shader)
{ {
@ -258,7 +257,6 @@ namespace ControlCatalog.Pages
protected unsafe override void OnOpenGlInit(GlInterface GL, int fb) protected unsafe override void OnOpenGlInit(GlInterface GL, int fb)
{ {
CheckError(GL); CheckError(GL);
_glExt = new GlExtrasInterface(GL);
Info = $"Renderer: {GL.GetString(GL_RENDERER)} Version: {GL.GetString(GL_VERSION)}"; Info = $"Renderer: {GL.GetString(GL_RENDERER)} Version: {GL.GetString(GL_VERSION)}";
@ -298,8 +296,8 @@ namespace ControlCatalog.Pages
GL.BufferData(GL_ELEMENT_ARRAY_BUFFER, new IntPtr(_indices.Length * sizeof(ushort)), new IntPtr(pdata), GL.BufferData(GL_ELEMENT_ARRAY_BUFFER, new IntPtr(_indices.Length * sizeof(ushort)), new IntPtr(pdata),
GL_STATIC_DRAW); GL_STATIC_DRAW);
CheckError(GL); CheckError(GL);
_vertexArrayObject = _glExt.GenVertexArray(); _vertexArrayObject = GL.GenVertexArray();
_glExt.BindVertexArray(_vertexArrayObject); GL.BindVertexArray(_vertexArrayObject);
CheckError(GL); CheckError(GL);
GL.VertexAttribPointer(positionLocation, 3, GL_FLOAT, GL.VertexAttribPointer(positionLocation, 3, GL_FLOAT,
0, vertexSize, IntPtr.Zero); 0, vertexSize, IntPtr.Zero);
@ -316,12 +314,13 @@ namespace ControlCatalog.Pages
// Unbind everything // Unbind everything
GL.BindBuffer(GL_ARRAY_BUFFER, 0); GL.BindBuffer(GL_ARRAY_BUFFER, 0);
GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
_glExt.BindVertexArray(0); GL.BindVertexArray(0);
GL.UseProgram(0); GL.UseProgram(0);
// Delete all resources. // Delete all resources.
GL.DeleteBuffers(2, new[] { _vertexBufferObject, _indexBufferObject }); GL.DeleteBuffer(_vertexBufferObject);
_glExt.DeleteVertexArrays(1, new[] { _vertexArrayObject }); GL.DeleteBuffer(_indexBufferObject);
GL.DeleteVertexArray(_vertexArrayObject);
GL.DeleteProgram(_shaderProgram); GL.DeleteProgram(_shaderProgram);
GL.DeleteShader(_fragmentShader); GL.DeleteShader(_fragmentShader);
GL.DeleteShader(_vertexShader); GL.DeleteShader(_vertexShader);
@ -338,7 +337,7 @@ namespace ControlCatalog.Pages
GL.BindBuffer(GL_ARRAY_BUFFER, _vertexBufferObject); GL.BindBuffer(GL_ARRAY_BUFFER, _vertexBufferObject);
GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBufferObject); GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBufferObject);
_glExt.BindVertexArray(_vertexArrayObject); GL.BindVertexArray(_vertexArrayObject);
GL.UseProgram(_shaderProgram); GL.UseProgram(_shaderProgram);
CheckError(GL); CheckError(GL);
var projection = var projection =
@ -369,34 +368,5 @@ namespace ControlCatalog.Pages
if (_disco > 0.01) if (_disco > 0.01)
Dispatcher.UIThread.Post(InvalidateVisual, DispatcherPriority.Background); Dispatcher.UIThread.Post(InvalidateVisual, DispatcherPriority.Background);
} }
class GlExtrasInterface : GlInterfaceBase<GlInterface.GlContextInfo>
{
public GlExtrasInterface(GlInterface gl) : base(gl.GetProcAddress, gl.ContextInfo)
{
}
public delegate void GlDeleteVertexArrays(int count, int[] buffers);
[GlMinVersionEntryPoint("glDeleteVertexArrays", 3,0)]
[GlExtensionEntryPoint("glDeleteVertexArraysOES", "GL_OES_vertex_array_object")]
public GlDeleteVertexArrays DeleteVertexArrays { get; }
public delegate void GlBindVertexArray(int array);
[GlMinVersionEntryPoint("glBindVertexArray", 3,0)]
[GlExtensionEntryPoint("glBindVertexArrayOES", "GL_OES_vertex_array_object")]
public GlBindVertexArray BindVertexArray { get; }
public delegate void GlGenVertexArrays(int n, int[] rv);
[GlMinVersionEntryPoint("glGenVertexArrays",3,0)]
[GlExtensionEntryPoint("glGenVertexArraysOES", "GL_OES_vertex_array_object")]
public GlGenVertexArrays GenVertexArrays { get; }
public int GenVertexArray()
{
var rv = new int[1];
GenVertexArrays(1, rv);
return rv[0];
}
}
} }
} }

27
samples/ControlCatalog/ViewModels/ExpanderPageViewModel.cs

@ -0,0 +1,27 @@
using Avalonia;
using MiniMvvm;
namespace ControlCatalog.ViewModels
{
public class ExpanderPageViewModel : ViewModelBase
{
private object _cornerRadius = AvaloniaProperty.UnsetValue;
private bool _rounded;
public object CornerRadius
{
get => _cornerRadius;
private set => RaiseAndSetIfChanged(ref _cornerRadius, value);
}
public bool Rounded
{
get => _rounded;
set
{
if (RaiseAndSetIfChanged(ref _rounded, value))
CornerRadius = _rounded ? new CornerRadius(25) : AvaloniaProperty.UnsetValue;
}
}
}
}

8
samples/RenderDemo/App.xaml

@ -3,6 +3,12 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Styles> <Application.Styles>
<FluentTheme /> <FluentTheme />
<StyleInclude Source="avares://ControlSamples/HamburgerMenu/HamburgerMenu.xaml" />
</Application.Styles> </Application.Styles>
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceInclude Source="avares://ControlSamples/HamburgerMenu/HamburgerMenu.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application> </Application>

286
samples/SampleControls/HamburgerMenu/HamburgerMenu.xaml

@ -1,6 +1,6 @@
<Styles xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:catalog="using:ControlSamples"> xmlns:catalog="using:ControlSamples">
<Design.PreviewWith> <Design.PreviewWith>
<Border Width="400" <Border Width="400"
Height="150"> Height="150">
@ -20,25 +20,136 @@
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Styles.Resources> <x:Double x:Key="PaneCompactWidth">40</x:Double>
<x:Double x:Key="PaneCompactWidth">40</x:Double> <x:Double x:Key="PaneExpandWidth">220</x:Double>
<x:Double x:Key="PaneExpandWidth">220</x:Double> <x:Double x:Key="HeaderHeight">36</x:Double>
<x:Double x:Key="HeaderHeight">36</x:Double> <x:Double x:Key="NavigationItemHeight">36</x:Double>
<x:Double x:Key="NavigationItemHeight">36</x:Double> <x:Double x:Key="HamburgerMenuButtonHeight">32</x:Double>
<x:Double x:Key="HamburgerMenuButtonHeight">32</x:Double> <Thickness x:Key="HeaderMarginCollapsedPane">12,0,0,0</Thickness>
<Thickness x:Key="HeaderMarginCollapsedPane">12,0,0,0</Thickness> <Thickness x:Key="HeaderMarginExpandedPane">52,0,0,0</Thickness>
<Thickness x:Key="HeaderMarginExpandedPane">52,0,0,0</Thickness> <Thickness x:Key="HeaderMarginExpandedOverlayPane">212,0,0,0</Thickness>
<Thickness x:Key="HeaderMarginExpandedOverlayPane">212,0,0,0</Thickness> <BoxShadows x:Key="NavigationItemShadow">1 1 1 1 #2000, 0 0 1 1 #2fff</BoxShadows>
<BoxShadows x:Key="NavigationItemShadow">1 1 1 1 #2000, 0 0 1 1 #2fff</BoxShadows> <BoxShadows x:Key="NavigationContentShadow">0 0 1 1 #2000</BoxShadows>
<BoxShadows x:Key="NavigationContentShadow">0 0 1 1 #2000</BoxShadows>
</Styles.Resources> <ControlTheme x:Key="NavigationButton" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="MinHeight" Value="0" />
<Setter Property="Height" Value="{StaticResource NavigationItemHeight}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Padding" Value="12,0,4,0" />
<Setter Property="Margin" Value="4,0,8,0" />
<Setter Property="CornerRadius" Value="8" />
<Setter Property="ClipToBounds" Value="False" />
<Setter Property="Template">
<ControlTemplate>
<ContentPresenter Name="PART_ContentPresenter"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
CornerRadius="{TemplateBinding CornerRadius}"
TextElement.FontFamily="{TemplateBinding FontFamily}"
TextElement.FontSize="{TemplateBinding FontSize}"
TextElement.FontWeight="{TemplateBinding FontWeight}" />
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover /template/ ContentPresenter">
<Setter Property="Border.Background" Value="{DynamicResource SystemChromeLowColor}" />
<Setter Property="Border.BoxShadow" Value="{StaticResource NavigationItemShadow}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource TabItemHeaderForegroundUnselectedPointerOver}" />
</Style>
</ControlTheme>
<ControlTheme x:Key="HamburgerMenuTabItem" TargetType="TabItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="MinHeight" Value="0" />
<Setter Property="Height" Value="{StaticResource NavigationItemHeight}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Padding" Value="12,0,4,0" />
<Setter Property="Margin" Value="4,0,8,0" />
<Setter Property="CornerRadius" Value="8" />
<Setter Property="ClipToBounds" Value="False" />
<Setter Property="Template">
<ControlTemplate>
<Border Name="PART_LayoutRoot"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<Panel>
<Border Name="PART_SelectedPipe"
Width="{DynamicResource TabItemPipeThickness}"
Height="{DynamicResource TabItemVerticalPipeHeight}"
Margin="6,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Background="{DynamicResource TabItemHeaderSelectedPipeFill}"
IsVisible="False"
CornerRadius="{DynamicResource ControlCornerRadius}"/>
<ContentPresenter Name="PART_ContentPresenter"
Padding="{TemplateBinding Padding}"
Margin="0"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
TextElement.FontFamily="{TemplateBinding FontFamily}"
TextElement.FontSize="{TemplateBinding FontSize}"
TextElement.FontWeight="{TemplateBinding FontWeight}" />
</Panel>
</Border>
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover">
<Setter Property="Background" Value="{DynamicResource ThemeControlHighlightMidBrush}"/>
<Style Selector="^ /template/ Border#PART_LayoutRoot">
<Setter Property="Background" Value="{DynamicResource SystemChromeLowColor}" />
<Setter Property="BoxShadow" Value="{StaticResource NavigationItemShadow}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource TabItemHeaderForegroundUnselectedPointerOver}" />
</Style>
</Style>
<Style Selector="^:selected">
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush4}"/>
<Style Selector="^ /template/ Border#PART_SelectedPipe">
<Setter Property="IsVisible" Value="True" />
</Style>
</Style>
<Style Selector="^:pressed /template/ Border#PART_LayoutRoot">
<Setter Property="Border.Background" Value="{DynamicResource SystemChromeLowColor}" />
<Setter Property="Border.BoxShadow" Value="{StaticResource NavigationItemShadow}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource TabItemHeaderForegroundUnselectedPressed}" />
</Style>
</ControlTheme>
<!-- HamburgerMenu --> <!-- HamburgerMenu -->
<Style Selector="catalog|HamburgerMenu"> <ControlTheme x:Key="{x:Type catalog:HamburgerMenu}" TargetType="catalog:HamburgerMenu">
<Setter Property="Padding" Value="12 8 4 0" /> <Setter Property="Padding" Value="12 8 4 0" />
<Setter Property="PaneBackground" Value="{DynamicResource SystemChromeMediumColor}" /> <Setter Property="PaneBackground" Value="{DynamicResource SystemChromeMediumColor}" />
<Setter Property="Background" Value="{DynamicResource SystemChromeMediumColor}" /> <Setter Property="Background" Value="{DynamicResource SystemChromeMediumColor}" />
<Setter Property="ContentBackground" Value="{DynamicResource SystemAltHighColor}" /> <Setter Property="ContentBackground" Value="{DynamicResource SystemAltHighColor}" />
<Setter Property="ItemContainerTheme" Value="{StaticResource HamburgerMenuTabItem}"/>
<Setter Property="TabStripPlacement" Value="Left" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Panel Background="{TemplateBinding PaneBackground}"> <Panel Background="{TemplateBinding PaneBackground}">
@ -46,7 +157,8 @@
CompactPaneLength="{StaticResource PaneCompactWidth}" CompactPaneLength="{StaticResource PaneCompactWidth}"
DisplayMode="Inline" DisplayMode="Inline"
IsPaneOpen="True" IsPaneOpen="True"
OpenPaneLength="{StaticResource PaneExpandWidth}"> OpenPaneLength="{StaticResource PaneExpandWidth}"
PaneBackground="Transparent">
<SplitView.Pane> <SplitView.Pane>
<Grid Margin="0,0,1,5" RowDefinitions="Auto, *, Auto"> <Grid Margin="0,0,1,5" RowDefinitions="Auto, *, Auto">
<Panel Height="{StaticResource HeaderHeight}" /> <Panel Height="{StaticResource HeaderHeight}" />
@ -58,8 +170,7 @@
<ItemsPresenter Name="PART_ItemsPresenter" <ItemsPresenter Name="PART_ItemsPresenter"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
ItemTemplate="{TemplateBinding ItemTemplate}" ItemTemplate="{TemplateBinding ItemTemplate}"
Items="{TemplateBinding Items}" Items="{TemplateBinding Items}">
ItemsPanel="{TemplateBinding ItemsPanel}">
<ItemsPresenter.ItemsPanel> <ItemsPresenter.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<StackPanel x:Name="HamburgerItemsPanel" <StackPanel x:Name="HamburgerItemsPanel"
@ -70,7 +181,7 @@
</ScrollViewer> </ScrollViewer>
<Button x:Name="SettingsButton" <Button x:Name="SettingsButton"
Grid.Row="2" Grid.Row="2"
Classes="NavigationButton" Theme="{StaticResource NavigationButton}"
Content="Settings" Content="Settings"
Flyout="{TemplateBinding (FlyoutBase.AttachedFlyout)}" Flyout="{TemplateBinding (FlyoutBase.AttachedFlyout)}"
IsVisible="{Binding $parent[TabControl].(FlyoutBase.AttachedFlyout), Converter={x:Static ObjectConverters.IsNotNull}}" /> IsVisible="{Binding $parent[TabControl].(FlyoutBase.AttachedFlyout), Converter={x:Static ObjectConverters.IsNotNull}}" />
@ -82,6 +193,7 @@
<TextBlock x:Name="HeaderHolder" <TextBlock x:Name="HeaderHolder"
VerticalAlignment="Center" VerticalAlignment="Center"
Classes="h1" Classes="h1"
Margin="{StaticResource HeaderMarginExpandedPane}"
Text="{Binding $parent[TabControl].SelectedItem.Header, FallbackValue=''}"> Text="{Binding $parent[TabControl].SelectedItem.Header, FallbackValue=''}">
<TextBlock.Transitions> <TextBlock.Transitions>
<Transitions> <Transitions>
@ -119,7 +231,7 @@
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Top" VerticalAlignment="Top"
HorizontalContentAlignment="Center" HorizontalContentAlignment="Center"
Classes="NavigationButton" Theme="{StaticResource NavigationButton}"
CornerRadius="4" CornerRadius="4"
IsChecked="{Binding #PART_NavigationPane.IsPaneOpen, Mode=TwoWay}"> IsChecked="{Binding #PART_NavigationPane.IsPaneOpen, Mode=TwoWay}">
<PathIcon Data="M3 17h18a1 1 0 0 1 .117 1.993L21 19H3a1 1 0 0 1-.117-1.993L3 17h18H3Zm0-6 18-.002a1 1 0 0 1 .117 1.993l-.117.007L3 13a1 1 0 0 1-.117-1.993L3 11l18-.002L3 11Zm0-6h18a1 1 0 0 1 .117 1.993L21 7H3a1 1 0 0 1-.117-1.993L3 5h18H3Z" Foreground="{TemplateBinding Foreground}" /> <PathIcon Data="M3 17h18a1 1 0 0 1 .117 1.993L21 19H3a1 1 0 0 1-.117-1.993L3 17h18H3Zm0-6 18-.002a1 1 0 0 1 .117 1.993l-.117.007L3 13a1 1 0 0 1-.117-1.993L3 11l18-.002L3 11Zm0-6h18a1 1 0 0 1 .117 1.993L21 7H3a1 1 0 0 1-.117-1.993L3 5h18H3Z" Foreground="{TemplateBinding Foreground}" />
@ -127,116 +239,26 @@
</Panel> </Panel>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style>
<Style Selector="catalog|HamburgerMenu /template/ SplitView TextBlock#HeaderHolder"> <Style Selector="^ /template/ SplitView[IsPaneOpen=True] TextBlock#HeaderHolder">
<Setter Property="Margin" Value="{StaticResource HeaderMarginExpandedPane}" /> <Setter Property="Margin" Value="{StaticResource HeaderMarginCollapsedPane}" />
</Style> </Style>
<Style Selector="catalog|HamburgerMenu /template/ SplitView[IsPaneOpen=True] TextBlock#HeaderHolder"> <Style Selector="^ /template/ SplitView[DisplayMode=Overlay][IsPaneOpen=True] TextBlock#HeaderHolder">
<Setter Property="Margin" Value="{StaticResource HeaderMarginCollapsedPane}" /> <Setter Property="Margin" Value="{StaticResource HeaderMarginExpandedOverlayPane}" />
</Style> </Style>
<Style Selector="catalog|HamburgerMenu /template/ SplitView[DisplayMode=Overlay][IsPaneOpen=True] TextBlock#HeaderHolder"> <Style Selector="^ /template/ SplitView[DisplayMode=Overlay]">
<Setter Property="Margin" Value="{StaticResource HeaderMarginExpandedOverlayPane}" /> <Setter Property="PaneBackground" Value="{TemplateBinding PaneBackground}" />
</Style> </Style>
<Style Selector="catalog|HamburgerMenu /template/ SplitView"> <Style Selector="^ /template/ SplitView[DisplayMode=Overlay]">
<Setter Property="PaneBackground" Value="Transparent" /> <Setter Property="Background" Value="{Binding $parent[TabControl].ContentBackground}" />
</Style> </Style>
<Style Selector="catalog|HamburgerMenu /template/ SplitView[DisplayMode=Overlay]"> <Style Selector="^ /template/ SplitView[DisplayMode=Inline] Border#BackgroundBorder">
<Setter Property="PaneBackground" Value="{TemplateBinding PaneBackground}" /> <Setter Property="Background" Value="{Binding $parent[TabControl].ContentBackground}" />
</Style> <Setter Property="BoxShadow" Value="{StaticResource NavigationContentShadow}" />
<Style Selector="catalog|HamburgerMenu /template/ SplitView[DisplayMode=Overlay]"> </Style>
<Setter Property="Background" Value="{Binding $parent[TabControl].ContentBackground}" /> <Style Selector="^ /template/ SplitView[DisplayMode=Inline][IsPaneOpen=True] Border#BackgroundBorder">
</Style> <Setter Property="CornerRadius" Value="8 0 0 0" />
<Style Selector="catalog|HamburgerMenu /template/ SplitView[DisplayMode=Inline] Border#BackgroundBorder"> </Style>
<Setter Property="Background" Value="{Binding $parent[TabControl].ContentBackground}" /> </ControlTheme>
<Setter Property="BoxShadow" Value="{StaticResource NavigationContentShadow}" />
</Style>
<Style Selector="catalog|HamburgerMenu /template/ SplitView[DisplayMode=Inline][IsPaneOpen=True] Border#BackgroundBorder">
<Setter Property="CornerRadius" Value="8 0 0 0" />
</Style>
</ResourceDictionary>
<!-- HamburgerMenu TabItem -->
<Style Selector="catalog|HamburgerMenu > TabItem, :is(Button).NavigationButton">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="MinHeight" Value="0" />
<Setter Property="Height" Value="{StaticResource NavigationItemHeight}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Padding" Value="12,0,4,0" />
<Setter Property="Margin" Value="4,0,8,0" />
<Setter Property="CornerRadius" Value="8" />
<Setter Property="ClipToBounds" Value="False" />
</Style>
<Style Selector="catalog|HamburgerMenu > TabItem">
<Setter Property="Template">
<ControlTemplate>
<Border Name="PART_LayoutRoot"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<Panel>
<Border Name="PART_SelectedPipe"
Width="{DynamicResource TabItemPipeThickness}"
Height="{DynamicResource TabItemVerticalPipeHeight}"
Margin="6,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Background="{DynamicResource TabItemHeaderSelectedPipeFill}" />
<ContentPresenter Name="PART_ContentPresenter"
Padding="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
TextElement.FontFamily="{TemplateBinding FontFamily}"
TextElement.FontSize="{TemplateBinding FontSize}"
TextElement.FontWeight="{TemplateBinding FontWeight}" />
</Panel>
</Border>
</ControlTemplate>
</Setter>
</Style>
<Style Selector=":is(Button).NavigationButton">
<Setter Property="Template">
<ControlTemplate>
<ContentPresenter Name="PART_ContentPresenter"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
CornerRadius="{TemplateBinding CornerRadius}"
TextElement.FontFamily="{TemplateBinding FontFamily}"
TextElement.FontSize="{TemplateBinding FontSize}"
TextElement.FontWeight="{TemplateBinding FontWeight}" />
</ControlTemplate>
</Setter>
</Style>
<Style Selector="catalog|HamburgerMenu > TabItem /template/ Border#PART_LayoutRoot, :is(Button).NavigationButton /template/ ContentPresenter">
<Setter Property="Border.Background" Value="Transparent" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource SystemBaseHighColor}" />
</Style>
<Style Selector="catalog|HamburgerMenu > TabItem:pointerover /template/ Border#PART_LayoutRoot, :is(Button).NavigationButton:pointerover /template/ ContentPresenter">
<Setter Property="Border.Background" Value="{DynamicResource SystemChromeLowColor}" />
<Setter Property="Border.BoxShadow" Value="{StaticResource NavigationItemShadow}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource TabItemHeaderForegroundUnselectedPointerOver}" />
</Style>
<Style Selector="catalog|HamburgerMenu > TabItem:pressed /template/ Border#PART_LayoutRoot, :is(Button).NavigationButton:pressed /template/ ContentPresenter">
<Setter Property="Border.Background" Value="{DynamicResource SystemChromeLowColor}" />
<Setter Property="Border.BoxShadow" Value="{StaticResource NavigationItemShadow}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource TabItemHeaderForegroundUnselectedPressed}" />
</Style>
<Style Selector=":is(Button).NavigationButton:pressed">
<Setter Property="RenderTransform" Value="none" />
</Style>
</Styles>

5
src/Avalonia.Base/Input/Cursor.cs

@ -32,10 +32,7 @@ namespace Avalonia.Input
DragCopy, DragCopy,
DragLink, DragLink,
None, None,
[Obsolete("Use BottomSide")]
BottomSize = BottomSide
// Not available in GTK directly, see http://www.pixelbeat.org/programming/x_cursors/ // Not available in GTK directly, see http://www.pixelbeat.org/programming/x_cursors/
// We might enable them later, preferably, by loading pixmax directly from theme with fallback image // We might enable them later, preferably, by loading pixmax directly from theme with fallback image
// SizeNorthWestSouthEast, // SizeNorthWestSouthEast,

18
src/Avalonia.Base/Input/DragEventArgs.cs

@ -13,9 +13,6 @@ namespace Avalonia.Input
public IDataObject Data { get; private set; } public IDataObject Data { get; private set; }
[Obsolete("Use KeyModifiers")]
public InputModifiers Modifiers { get; private set; }
public KeyModifiers KeyModifiers { get; private set; } public KeyModifiers KeyModifiers { get; private set; }
public Point GetPosition(IVisual relativeTo) public Point GetPosition(IVisual relativeTo)
@ -35,17 +32,6 @@ namespace Avalonia.Input
return point; return point;
} }
[Obsolete("Use constructor taking KeyModifiers")]
public DragEventArgs(RoutedEvent<DragEventArgs> routedEvent, IDataObject data, Interactive target, Point targetLocation, InputModifiers modifiers)
: base(routedEvent)
{
Data = data;
_target = target;
_targetLocation = targetLocation;
Modifiers = modifiers;
KeyModifiers = (KeyModifiers)(((int)modifiers) & 0xF);
}
public DragEventArgs(RoutedEvent<DragEventArgs> routedEvent, IDataObject data, Interactive target, Point targetLocation, KeyModifiers keyModifiers) public DragEventArgs(RoutedEvent<DragEventArgs> routedEvent, IDataObject data, Interactive target, Point targetLocation, KeyModifiers keyModifiers)
: base(routedEvent) : base(routedEvent)
{ {
@ -53,10 +39,6 @@ namespace Avalonia.Input
_target = target; _target = target;
_targetLocation = targetLocation; _targetLocation = targetLocation;
KeyModifiers = keyModifiers; KeyModifiers = keyModifiers;
#pragma warning disable CS0618 // Type or member is obsolete
Modifiers = (InputModifiers)keyModifiers;
#pragma warning restore CS0618 // Type or member is obsolete
} }
} }
} }

11
src/Avalonia.Base/Input/GotFocusEventArgs.cs

@ -1,4 +1,3 @@
using System;
using Avalonia.Interactivity; using Avalonia.Interactivity;
namespace Avalonia.Input namespace Avalonia.Input
@ -13,16 +12,6 @@ namespace Avalonia.Input
/// </summary> /// </summary>
public NavigationMethod NavigationMethod { get; set; } public NavigationMethod NavigationMethod { get; set; }
/// <summary>
/// Gets or sets any input modifiers active at the time of focus.
/// </summary>
[Obsolete("Use KeyModifiers")]
public InputModifiers InputModifiers
{
get => (InputModifiers)KeyModifiers;
set => KeyModifiers = (KeyModifiers)((int)value & 0xF);
}
/// <summary> /// <summary>
/// Gets or sets any key modifiers active at the time of focus. /// Gets or sets any key modifiers active at the time of focus.
/// </summary> /// </summary>

5
src/Avalonia.Base/Input/IInputRoot.cs

@ -27,10 +27,5 @@ namespace Avalonia.Input
/// Gets or sets a value indicating whether access keys are shown in the window. /// Gets or sets a value indicating whether access keys are shown in the window.
/// </summary> /// </summary>
bool ShowAccessKeys { get; set; } bool ShowAccessKeys { get; set; }
/// <summary>
/// Gets associated mouse device
/// </summary>
IMouseDevice? MouseDevice { get; }
} }
} }

13
src/Avalonia.Base/Input/IKeyboardDevice.cs

@ -4,19 +4,6 @@ using Avalonia.Metadata;
namespace Avalonia.Input namespace Avalonia.Input
{ {
[Flags, Obsolete("Use KeyModifiers and PointerPointProperties")]
public enum InputModifiers
{
None = 0,
Alt = 1,
Control = 2,
Shift = 4,
Windows = 8,
LeftMouseButton = 16,
RightMouseButton = 32,
MiddleMouseButton = 64
}
[Flags] [Flags]
public enum KeyModifiers public enum KeyModifiers
{ {

12
src/Avalonia.Base/Input/IMouseDevice.cs

@ -1,4 +1,3 @@
using System;
using Avalonia.Metadata; using Avalonia.Metadata;
namespace Avalonia.Input namespace Avalonia.Input
@ -9,16 +8,5 @@ namespace Avalonia.Input
[NotClientImplementable] [NotClientImplementable]
public interface IMouseDevice : IPointerDevice public interface IMouseDevice : IPointerDevice
{ {
/// <summary>
/// Gets the mouse position, in screen coordinates.
/// </summary>
[Obsolete("Use PointerEventArgs.GetPosition")]
PixelPoint Position { get; }
[Obsolete]
void TopLevelClosed(IInputRoot root);
[Obsolete]
void SceneInvalidated(IInputRoot root, Rect rect);
} }
} }

14
src/Avalonia.Base/Input/IPointerDevice.cs

@ -1,5 +1,3 @@
using System;
using Avalonia.VisualTree;
using Avalonia.Input.Raw; using Avalonia.Input.Raw;
using Avalonia.Metadata; using Avalonia.Metadata;
@ -8,18 +6,6 @@ namespace Avalonia.Input
[NotClientImplementable] [NotClientImplementable]
public interface IPointerDevice : IInputDevice public interface IPointerDevice : IInputDevice
{ {
/// <inheritdoc cref="IPointer.Captured" />
[Obsolete("Use IPointer")]
IInputElement? Captured { get; }
/// <inheritdoc cref="IPointer.Capture(IInputElement?)" />
[Obsolete("Use IPointer")]
void Capture(IInputElement? control);
/// <inheritdoc cref="PointerEventArgs.GetPosition(IVisual?)" />
[Obsolete("Use PointerEventArgs.GetPosition")]
Point GetPosition(IVisual relativeTo);
/// <summary> /// <summary>
/// Gets a pointer for specific event args. /// Gets a pointer for specific event args.
/// </summary> /// </summary>

2
src/Avalonia.Base/Input/KeyEventArgs.cs

@ -9,8 +9,6 @@ namespace Avalonia.Input
public Key Key { get; set; } public Key Key { get; set; }
[Obsolete("Use KeyModifiers")]
public InputModifiers Modifiers => (InputModifiers)KeyModifiers;
public KeyModifiers KeyModifiers { get; set; } public KeyModifiers KeyModifiers { get; set; }
} }
} }

12
src/Avalonia.Base/Input/KeyGesture.cs

@ -15,13 +15,6 @@ namespace Avalonia.Input
{ "+", Key.OemPlus }, { "-", Key.OemMinus }, { ".", Key.OemPeriod }, { ",", Key.OemComma } { "+", Key.OemPlus }, { "-", Key.OemMinus }, { ".", Key.OemPeriod }, { ",", Key.OemComma }
}; };
[Obsolete("Use constructor taking KeyModifiers")]
public KeyGesture(Key key, InputModifiers modifiers)
{
Key = key;
KeyModifiers = (KeyModifiers)(((int)modifiers) & 0xf);
}
public KeyGesture(Key key, KeyModifiers modifiers = KeyModifiers.None) public KeyGesture(Key key, KeyModifiers modifiers = KeyModifiers.None)
{ {
Key = key; Key = key;
@ -63,10 +56,7 @@ namespace Avalonia.Input
} }
public Key Key { get; } public Key Key { get; }
[Obsolete("Use KeyModifiers")]
public InputModifiers Modifiers => (InputModifiers)KeyModifiers;
public KeyModifiers KeyModifiers { get; } public KeyModifiers KeyModifiers { get; }
public static KeyGesture Parse(string gesture) public static KeyGesture Parse(string gesture)

54
src/Avalonia.Base/Input/MouseDevice.cs

@ -21,7 +21,6 @@ namespace Avalonia.Input
private readonly Pointer _pointer; private readonly Pointer _pointer;
private bool _disposed; private bool _disposed;
private PixelPoint? _position;
private MouseButton _lastMouseDownButton; private MouseButton _lastMouseDownButton;
public MouseDevice(Pointer? pointer = null) public MouseDevice(Pointer? pointer = null)
@ -29,43 +28,6 @@ namespace Avalonia.Input
_pointer = pointer ?? new Pointer(Pointer.GetNextFreeId(), PointerType.Mouse, true); _pointer = pointer ?? new Pointer(Pointer.GetNextFreeId(), PointerType.Mouse, true);
} }
[Obsolete("Use IPointer instead")]
public IInputElement? Captured => _pointer.Captured;
[Obsolete("Use events instead")]
public PixelPoint Position
{
get => _position ?? new PixelPoint(-1, -1);
protected set => _position = value;
}
[Obsolete("Use IPointer instead")]
public void Capture(IInputElement? control)
{
_pointer.Capture(control);
}
/// <summary>
/// Gets the mouse position relative to a control.
/// </summary>
/// <param name="relativeTo">The control.</param>
/// <returns>The mouse position in the control's coordinates.</returns>
public Point GetPosition(IVisual relativeTo)
{
relativeTo = relativeTo ?? throw new ArgumentNullException(nameof(relativeTo));
if (relativeTo.VisualRoot == null)
{
throw new InvalidOperationException("Control is not attached to visual tree.");
}
#pragma warning disable CS0618 // Type or member is obsolete
var rootPoint = relativeTo.VisualRoot.PointToClient(Position);
#pragma warning restore CS0618 // Type or member is obsolete
var transform = relativeTo.VisualRoot.TransformToVisual(relativeTo);
return rootPoint * transform!.Value;
}
public void ProcessRawEvent(RawInputEventArgs e) public void ProcessRawEvent(RawInputEventArgs e)
{ {
if (!e.Handled && e is RawPointerEventArgs margs) if (!e.Handled && e is RawPointerEventArgs margs)
@ -96,7 +58,6 @@ namespace Avalonia.Input
if(mouse._disposed) if(mouse._disposed)
return; return;
_position = e.Root.PointToScreen(e.Position);
var props = CreateProperties(e); var props = CreateProperties(e);
var keyModifiers = e.InputModifiers.ToKeyModifiers(); var keyModifiers = e.InputModifiers.ToKeyModifiers();
switch (e.Type) switch (e.Type)
@ -145,7 +106,6 @@ namespace Avalonia.Input
private void LeaveWindow() private void LeaveWindow()
{ {
_position = null;
} }
PointerPointProperties CreateProperties(RawPointerEventArgs args) PointerPointProperties CreateProperties(RawPointerEventArgs args)
@ -324,19 +284,7 @@ namespace Avalonia.Input
_disposed = true; _disposed = true;
_pointer?.Dispose(); _pointer?.Dispose();
} }
[Obsolete]
public void TopLevelClosed(IInputRoot root)
{
// no-op
}
[Obsolete]
public void SceneInvalidated(IInputRoot root, Rect rect)
{
// no-op
}
public IPointer? TryGetPointer(RawPointerEventArgs ev) public IPointer? TryGetPointer(RawPointerEventArgs ev)
{ {
return _pointer; return _pointer;

19
src/Avalonia.Base/Input/PenDevice.cs

@ -1,10 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reactive.Linq;
using Avalonia.Input.Raw; using Avalonia.Input.Raw;
using Avalonia.Platform; using Avalonia.Platform;
using Avalonia.VisualTree;
namespace Avalonia.Input namespace Avalonia.Input
{ {
@ -14,7 +12,6 @@ namespace Avalonia.Input
public class PenDevice : IPenDevice, IDisposable public class PenDevice : IPenDevice, IDisposable
{ {
private readonly Dictionary<long, Pointer> _pointers = new(); private readonly Dictionary<long, Pointer> _pointers = new();
private readonly Dictionary<long, PixelPoint> _lastPositions = new();
private int _clickCount; private int _clickCount;
private Rect _lastClickRect; private Rect _lastClickRect;
private ulong _lastClickTime; private ulong _lastClickTime;
@ -41,9 +38,7 @@ namespace Avalonia.Input
_pointers[e.RawPointerId] = pointer = new Pointer(Pointer.GetNextFreeId(), _pointers[e.RawPointerId] = pointer = new Pointer(Pointer.GetNextFreeId(),
PointerType.Pen, _pointers.Count == 0); PointerType.Pen, _pointers.Count == 0);
} }
_lastPositions[e.RawPointerId] = e.Root.PointToScreen(e.Position);
var props = new PointerPointProperties(e.InputModifiers, e.Type.ToUpdateKind(), var props = new PointerPointProperties(e.InputModifiers, e.Type.ToUpdateKind(),
e.Point.Twist, e.Point.Pressure, e.Point.XTilt, e.Point.YTilt); e.Point.Twist, e.Point.Pressure, e.Point.XTilt, e.Point.YTilt);
var keyModifiers = e.InputModifiers.ToKeyModifiers(); var keyModifiers = e.InputModifiers.ToKeyModifiers();
@ -69,7 +64,6 @@ namespace Avalonia.Input
{ {
pointer.Dispose(); pointer.Dispose();
_pointers.Remove(e.RawPointerId); _pointers.Remove(e.RawPointerId);
_lastPositions.Remove(e.RawPointerId);
} }
} }
@ -153,17 +147,6 @@ namespace Avalonia.Input
p.Dispose(); p.Dispose();
} }
[Obsolete]
IInputElement? IPointerDevice.Captured => _pointers.Values
.FirstOrDefault(p => p.IsPrimary)?.Captured;
[Obsolete]
void IPointerDevice.Capture(IInputElement? control) => _pointers.Values
.FirstOrDefault(p => p.IsPrimary)?.Capture(control);
[Obsolete]
Point IPointerDevice.GetPosition(IVisual relativeTo) => new Point(-1, -1);
public IPointer? TryGetPointer(RawPointerEventArgs ev) public IPointer? TryGetPointer(RawPointerEventArgs ev)
{ {
return _pointers.TryGetValue(ev.RawPointerId, out var pointer) return _pointers.TryGetValue(ev.RawPointerId, out var pointer)

62
src/Avalonia.Base/Input/PointerEventArgs.cs

@ -11,7 +11,7 @@ namespace Avalonia.Input
private readonly IVisual? _rootVisual; private readonly IVisual? _rootVisual;
private readonly Point _rootVisualPosition; private readonly Point _rootVisualPosition;
private readonly PointerPointProperties _properties; private readonly PointerPointProperties _properties;
private Lazy<IReadOnlyList<RawPointerPoint>?>? _previousPoints; private readonly Lazy<IReadOnlyList<RawPointerPoint>?>? _previousPoints;
public PointerEventArgs(RoutedEvent routedEvent, public PointerEventArgs(RoutedEvent routedEvent,
IInteractive? source, IInteractive? source,
@ -43,29 +43,6 @@ namespace Avalonia.Input
{ {
_previousPoints = previousPoints; _previousPoints = previousPoints;
} }
class EmulatedDevice : IPointerDevice
{
private readonly PointerEventArgs _ev;
public EmulatedDevice(PointerEventArgs ev)
{
_ev = ev;
}
public void ProcessRawEvent(RawInputEventArgs ev) => throw new NotSupportedException();
public IInputElement? Captured => _ev.Pointer.Captured;
public void Capture(IInputElement? control)
{
_ev.Pointer.Capture(control);
}
public Point GetPosition(IVisual relativeTo) => _ev.GetPosition(relativeTo);
public IPointer? TryGetPointer(RawPointerEventArgs ev) => _ev.Pointer;
}
/// <summary> /// <summary>
/// Gets specific pointer generated by input device. /// Gets specific pointer generated by input device.
@ -77,28 +54,6 @@ namespace Avalonia.Input
/// </summary> /// </summary>
public ulong Timestamp { get; } public ulong Timestamp { get; }
private IPointerDevice? _device;
[Obsolete("Use Pointer to get pointer-specific information")]
public IPointerDevice Device => _device ?? (_device = new EmulatedDevice(this));
[Obsolete("Use KeyModifiers and PointerPointProperties")]
public InputModifiers InputModifiers
{
get
{
var mods = (InputModifiers)KeyModifiers;
if (_properties.IsLeftButtonPressed)
mods |= InputModifiers.LeftMouseButton;
if (_properties.IsMiddleButtonPressed)
mods |= InputModifiers.MiddleMouseButton;
if (_properties.IsRightButtonPressed)
mods |= InputModifiers.RightMouseButton;
return mods;
}
}
/// <summary> /// <summary>
/// Gets a value that indicates which key modifiers were active at the time that the pointer event was initiated. /// Gets a value that indicates which key modifiers were active at the time that the pointer event was initiated.
/// </summary> /// </summary>
@ -120,9 +75,6 @@ namespace Avalonia.Input
/// <returns>The pointer position in the control's coordinates.</returns> /// <returns>The pointer position in the control's coordinates.</returns>
public Point GetPosition(IVisual? relativeTo) => GetPosition(_rootVisualPosition, relativeTo); public Point GetPosition(IVisual? relativeTo) => GetPosition(_rootVisualPosition, relativeTo);
[Obsolete("Use GetCurrentPoint")]
public PointerPoint GetPointerPoint(IVisual? relativeTo) => GetCurrentPoint(relativeTo);
/// <summary> /// <summary>
/// Returns the PointerPoint associated with the current event /// Returns the PointerPoint associated with the current event
/// </summary> /// </summary>
@ -171,8 +123,6 @@ namespace Avalonia.Input
public class PointerPressedEventArgs : PointerEventArgs public class PointerPressedEventArgs : PointerEventArgs
{ {
private readonly int _clickCount;
public PointerPressedEventArgs( public PointerPressedEventArgs(
IInteractive source, IInteractive source,
IPointer pointer, IPointer pointer,
@ -184,13 +134,10 @@ namespace Avalonia.Input
: base(InputElement.PointerPressedEvent, source, pointer, rootVisual, rootVisualPosition, : base(InputElement.PointerPressedEvent, source, pointer, rootVisual, rootVisualPosition,
timestamp, properties, modifiers) timestamp, properties, modifiers)
{ {
_clickCount = clickCount; ClickCount = clickCount;
} }
public int ClickCount => _clickCount; public int ClickCount { get; }
[Obsolete("Use PointerPressedEventArgs.GetCurrentPoint(this).Properties")]
public MouseButton MouseButton => Properties.PointerUpdateKind.GetMouseButton();
} }
public class PointerReleasedEventArgs : PointerEventArgs public class PointerReleasedEventArgs : PointerEventArgs
@ -210,9 +157,6 @@ namespace Avalonia.Input
/// Gets the mouse button that triggered the corresponding PointerPressed event /// Gets the mouse button that triggered the corresponding PointerPressed event
/// </summary> /// </summary>
public MouseButton InitialPressMouseButton { get; } public MouseButton InitialPressMouseButton { get; }
[Obsolete("Use InitialPressMouseButton")]
public MouseButton MouseButton => InitialPressMouseButton;
} }
public class PointerCaptureLostEventArgs : RoutedEventArgs public class PointerCaptureLostEventArgs : RoutedEventArgs

2
src/Avalonia.Base/Input/PointerOverPreProcessor.cs

@ -15,6 +15,8 @@ namespace Avalonia.Input
_inputRoot = inputRoot ?? throw new ArgumentNullException(nameof(inputRoot)); _inputRoot = inputRoot ?? throw new ArgumentNullException(nameof(inputRoot));
} }
public PixelPoint? LastPosition => _lastPointer?.position;
public void OnCompleted() public void OnCompleted()
{ {
ClearPointerOver(); ClearPointerOver();

5
src/Avalonia.Base/Input/Raw/RawDragEvent.cs

@ -8,8 +8,6 @@ namespace Avalonia.Input.Raw
public IDataObject Data { get; } public IDataObject Data { get; }
public DragDropEffects Effects { get; set; } public DragDropEffects Effects { get; set; }
public RawDragEventType Type { get; } public RawDragEventType Type { get; }
[Obsolete("Use KeyModifiers")]
public InputModifiers Modifiers { get; }
public KeyModifiers KeyModifiers { get; } public KeyModifiers KeyModifiers { get; }
public RawDragEvent(IDragDropDevice inputDevice, RawDragEventType type, public RawDragEvent(IDragDropDevice inputDevice, RawDragEventType type,
@ -21,9 +19,6 @@ namespace Avalonia.Input.Raw
Data = data; Data = data;
Effects = effects; Effects = effects;
KeyModifiers = modifiers.ToKeyModifiers(); KeyModifiers = modifiers.ToKeyModifiers();
#pragma warning disable CS0618 // Type or member is obsolete
Modifiers = (InputModifiers)modifiers;
#pragma warning restore CS0618 // Type or member is obsolete
} }
} }
} }

3
src/Avalonia.Base/Input/Raw/RawTouchEventArgs.cs

@ -19,8 +19,5 @@ namespace Avalonia.Input.Raw
{ {
RawPointerId = rawPointerId; RawPointerId = rawPointerId;
} }
[Obsolete("Use RawPointerId")]
public long TouchPointId { get => RawPointerId; set => RawPointerId = value; }
} }
} }

11
src/Avalonia.Base/Input/TouchDevice.cs

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using Avalonia.Input.Raw; using Avalonia.Input.Raw;
using Avalonia.Platform; using Avalonia.Platform;
using Avalonia.VisualTree;
namespace Avalonia.Input namespace Avalonia.Input
{ {
@ -20,9 +19,6 @@ namespace Avalonia.Input
private int _clickCount; private int _clickCount;
private Rect _lastClickRect; private Rect _lastClickRect;
private ulong _lastClickTime; private ulong _lastClickTime;
private Pointer? _lastPointer;
IInputElement? IPointerDevice.Captured => _lastPointer?.Captured;
RawInputModifiers GetModifiers(RawInputModifiers modifiers, bool isLeftButtonDown) RawInputModifiers GetModifiers(RawInputModifiers modifiers, bool isLeftButtonDown)
{ {
@ -32,10 +28,6 @@ namespace Avalonia.Input
return rv; return rv;
} }
void IPointerDevice.Capture(IInputElement? control) => _lastPointer?.Capture(control);
Point IPointerDevice.GetPosition(IVisual relativeTo) => default;
public void ProcessRawEvent(RawInputEventArgs ev) public void ProcessRawEvent(RawInputEventArgs ev)
{ {
if (ev.Handled || _disposed) if (ev.Handled || _disposed)
@ -51,7 +43,6 @@ namespace Avalonia.Input
PointerType.Touch, _pointers.Count == 0); PointerType.Touch, _pointers.Count == 0);
pointer.Capture(hit); pointer.Capture(hit);
} }
_lastPointer = pointer;
var target = pointer.Captured ?? args.Root; var target = pointer.Captured ?? args.Root;
var updateKind = args.Type.ToUpdateKind(); var updateKind = args.Type.ToUpdateKind();
@ -96,7 +87,6 @@ namespace Avalonia.Input
new PointerPointProperties(GetModifiers(args.InputModifiers, false), updateKind), new PointerPointProperties(GetModifiers(args.InputModifiers, false), updateKind),
keyModifier, MouseButton.Left)); keyModifier, MouseButton.Left));
} }
_lastPointer = null;
} }
if (args.Type == RawPointerEventType.TouchCancel) if (args.Type == RawPointerEventType.TouchCancel)
@ -104,7 +94,6 @@ namespace Avalonia.Input
_pointers.Remove(args.RawPointerId); _pointers.Remove(args.RawPointerId);
using (pointer) using (pointer)
pointer.Capture(null); pointer.Capture(null);
_lastPointer = null;
} }
if (args.Type == RawPointerEventType.TouchUpdate) if (args.Type == RawPointerEventType.TouchUpdate)

5
src/Avalonia.Base/StyledElement.cs

@ -873,9 +873,12 @@ namespace Avalonia
if (applied.Source == styles[i]) if (applied.Source == styles[i])
{ {
applied.Dispose();
_appliedStyles.RemoveAt(j); _appliedStyles.RemoveAt(j);
applied.Dispose();
} }
if (j > _appliedStyles.Count)
j = _appliedStyles.Count;
} }
} }
} }

3
src/Avalonia.Build.Tasks/Avalonia.Build.Tasks.csproj

@ -95,6 +95,9 @@
<Compile Include="../Avalonia.Controls/GridLength.cs"> <Compile Include="../Avalonia.Controls/GridLength.cs">
<Link>Markup/%(RecursiveDir)%(FileName)%(Extension)</Link> <Link>Markup/%(RecursiveDir)%(FileName)%(Extension)</Link>
</Compile> </Compile>
<Compile Include="../Avalonia.Base/Data/BindingPriority.cs">
<Link>Markup/%(RecursiveDir)%(FileName)%(Extension)</Link>
</Compile>
<Compile Include="../Avalonia.Base/RelativePoint.cs"> <Compile Include="../Avalonia.Base/RelativePoint.cs">
<Link>Markup/%(RecursiveDir)%(FileName)%(Extension)</Link> <Link>Markup/%(RecursiveDir)%(FileName)%(Extension)</Link>
</Compile> </Compile>

3
src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs

@ -251,7 +251,8 @@ namespace Avalonia.Build.Tasks
var populateBuilder = classTypeDefinition == null ? var populateBuilder = classTypeDefinition == null ?
builder : builder :
typeSystem.CreateTypeBuilder(classTypeDefinition); typeSystem.CreateTypeBuilder(classTypeDefinition);
compiler.Compile(parsed, contextClass, compiler.Compile(parsed,
contextClass,
compiler.DefinePopulateMethod(populateBuilder, parsed, populateName, compiler.DefinePopulateMethod(populateBuilder, parsed, populateName,
classTypeDefinition == null), classTypeDefinition == null),
buildName == null ? null : compiler.DefineBuildMethod(builder, parsed, buildName, true), buildName == null ? null : compiler.DefineBuildMethod(builder, parsed, buildName, true),

27
src/Avalonia.Controls/Chrome/CaptionButtons.cs

@ -8,10 +8,10 @@ namespace Avalonia.Controls.Chrome
/// <summary> /// <summary>
/// Draws window minimize / maximize / close buttons in a <see cref="TitleBar"/> when managed client decorations are enabled. /// Draws window minimize / maximize / close buttons in a <see cref="TitleBar"/> when managed client decorations are enabled.
/// </summary> /// </summary>
[TemplatePart("PART_CloseButton", typeof(Panel))] [TemplatePart("PART_CloseButton", typeof(Button))]
[TemplatePart("PART_RestoreButton", typeof(Panel))] [TemplatePart("PART_RestoreButton", typeof(Button))]
[TemplatePart("PART_MinimiseButton", typeof(Panel))] [TemplatePart("PART_MinimiseButton", typeof(Button))]
[TemplatePart("PART_FullScreenButton", typeof(Panel))] [TemplatePart("PART_FullScreenButton", typeof(Button))]
[PseudoClasses(":minimized", ":normal", ":maximized", ":fullscreen")] [PseudoClasses(":minimized", ":normal", ":maximized", ":fullscreen")]
public class CaptionButtons : TemplatedControl public class CaptionButtons : TemplatedControl
{ {
@ -88,18 +88,15 @@ namespace Avalonia.Controls.Chrome
{ {
base.OnApplyTemplate(e); base.OnApplyTemplate(e);
var closeButton = e.NameScope.Get<Panel>("PART_CloseButton"); var closeButton = e.NameScope.Get<Button>("PART_CloseButton");
var restoreButton = e.NameScope.Get<Panel>("PART_RestoreButton"); var restoreButton = e.NameScope.Get<Button>("PART_RestoreButton");
var minimiseButton = e.NameScope.Get<Panel>("PART_MinimiseButton"); var minimiseButton = e.NameScope.Get<Button>("PART_MinimiseButton");
var fullScreenButton = e.NameScope.Get<Panel>("PART_FullScreenButton"); var fullScreenButton = e.NameScope.Get<Button>("PART_FullScreenButton");
closeButton.PointerReleased += (sender, e) => OnClose(); closeButton.Click += (sender, e) => OnClose();
restoreButton.Click += (sender, e) => OnRestore();
restoreButton.PointerReleased += (sender, e) => OnRestore(); minimiseButton.Click += (sender, e) => OnMinimize();
fullScreenButton.Click += (sender, e) => OnToggleFullScreen();
minimiseButton.PointerReleased += (sender, e) => OnMinimize();
fullScreenButton.PointerReleased += (sender, e) => OnToggleFullScreen();
} }
} }
} }

8
src/Avalonia.Controls/Chrome/TitleBar.cs

@ -44,13 +44,13 @@ namespace Avalonia.Controls.Chrome
base.OnApplyTemplate(e); base.OnApplyTemplate(e);
_captionButtons?.Detach(); _captionButtons?.Detach();
_captionButtons = e.NameScope.Get<CaptionButtons>("PART_CaptionButtons"); _captionButtons = e.NameScope.Get<CaptionButtons>("PART_CaptionButtons");
if (VisualRoot is Window window) if (VisualRoot is Window window)
{ {
_captionButtons?.Attach(window); _captionButtons?.Attach(window);
UpdateSize(window); UpdateSize(window);
} }
} }
@ -90,7 +90,7 @@ namespace Avalonia.Controls.Chrome
base.OnDetachedFromVisualTree(e); base.OnDetachedFromVisualTree(e);
_disposables?.Dispose(); _disposables?.Dispose();
_captionButtons?.Detach(); _captionButtons?.Detach();
_captionButtons = null; _captionButtons = null;
} }

2
src/Avalonia.Controls/DateTimePickers/DateTimePickerPanel.cs

@ -454,7 +454,7 @@ namespace Avalonia.Controls.Primitives
children.Add(new ListBoxItem children.Add(new ListBoxItem
{ {
Height = ItemHeight, Height = ItemHeight,
Classes = new Classes("DateTimePickerItem", $"{PanelType}Item"), Classes = new Classes($"{PanelType}Item"),
VerticalContentAlignment = Avalonia.Layout.VerticalAlignment.Center, VerticalContentAlignment = Avalonia.Layout.VerticalAlignment.Center,
Focusable = false Focusable = false
}); });

9
src/Avalonia.Controls/Platform/ITopLevelImpl.cs

@ -6,7 +6,6 @@ using Avalonia.Input.Raw;
using Avalonia.Layout; using Avalonia.Layout;
using Avalonia.Metadata; using Avalonia.Metadata;
using Avalonia.Rendering; using Avalonia.Rendering;
using JetBrains.Annotations;
namespace Avalonia.Platform namespace Avalonia.Platform
{ {
@ -151,13 +150,7 @@ namespace Avalonia.Platform
/// Gets or sets a method called when the input focus is lost. /// Gets or sets a method called when the input focus is lost.
/// </summary> /// </summary>
Action? LostFocus { get; set; } Action? LostFocus { get; set; }
/// <summary>
/// Gets a mouse device associated with toplevel
/// </summary>
[CanBeNull]
IMouseDevice MouseDevice { get; }
IPopupImpl? CreatePopup(); IPopupImpl? CreatePopup();
/// <summary> /// <summary>

11
src/Avalonia.Controls/Primitives/PopupPositioning/IPopupPositioner.cs

@ -45,6 +45,7 @@ Copyright © 2019 Nikita Tsukanov
*/ */
using System; using System;
using Avalonia.Input;
using Avalonia.Metadata; using Avalonia.Metadata;
using Avalonia.VisualTree; using Avalonia.VisualTree;
using Avalonia.Media; using Avalonia.Media;
@ -452,16 +453,14 @@ namespace Avalonia.Controls.Primitives.PopupPositioning
PopupPositionerConstraintAdjustment constraintAdjustment, Rect? rect, PopupPositionerConstraintAdjustment constraintAdjustment, Rect? rect,
FlowDirection flowDirection) FlowDirection flowDirection)
{ {
// We need a better way for tracking the last pointer position
#pragma warning disable CS0618 // Type or member is obsolete
var pointer = topLevel.PointToClient(topLevel.PlatformImpl?.MouseDevice.Position ?? default);
#pragma warning restore CS0618 // Type or member is obsolete
positionerParameters.Offset = offset; positionerParameters.Offset = offset;
positionerParameters.ConstraintAdjustment = constraintAdjustment; positionerParameters.ConstraintAdjustment = constraintAdjustment;
if (placement == PlacementMode.Pointer) if (placement == PlacementMode.Pointer)
{ {
positionerParameters.AnchorRectangle = new Rect(pointer, new Size(1, 1)); // We need a better way for tracking the last pointer position
var position = topLevel.PointToClient(topLevel.LastPointerPosition ?? default);
positionerParameters.AnchorRectangle = new Rect(position, new Size(1, 1));
positionerParameters.Anchor = PopupAnchor.TopLeft; positionerParameters.Anchor = PopupAnchor.TopLeft;
positionerParameters.Gravity = PopupGravity.BottomRight; positionerParameters.Gravity = PopupGravity.BottomRight;
} }

1
src/Avalonia.Controls/Remote/Server/RemoteServerTopLevelImpl.cs

@ -12,7 +12,6 @@ using Avalonia.Remote.Protocol;
using Avalonia.Remote.Protocol.Input; using Avalonia.Remote.Protocol.Input;
using Avalonia.Remote.Protocol.Viewport; using Avalonia.Remote.Protocol.Viewport;
using Avalonia.Threading; using Avalonia.Threading;
using InputModifiers = Avalonia.Input.InputModifiers;
using Key = Avalonia.Input.Key; using Key = Avalonia.Input.Key;
using PixelFormat = Avalonia.Platform.PixelFormat; using PixelFormat = Avalonia.Platform.PixelFormat;
using ProtocolPixelFormat = Avalonia.Remote.Protocol.Viewport.PixelFormat; using ProtocolPixelFormat = Avalonia.Remote.Protocol.Viewport.PixelFormat;

5
src/Avalonia.Controls/TopLevel.cs

@ -285,6 +285,8 @@ namespace Avalonia.Controls
/// </summary> /// </summary>
public IRenderer Renderer { get; private set; } public IRenderer Renderer { get; private set; }
internal PixelPoint? LastPointerPosition => _pointerOverPreProcessor?.LastPosition;
/// <summary> /// <summary>
/// Gets the access key handler for the window. /// Gets the access key handler for the window.
/// </summary> /// </summary>
@ -302,9 +304,6 @@ namespace Avalonia.Controls
set { SetValue(PointerOverElementProperty, value); } set { SetValue(PointerOverElementProperty, value); }
} }
/// <inheritdoc/>
IMouseDevice? IInputRoot.MouseDevice => PlatformImpl?.MouseDevice;
/// <summary> /// <summary>
/// Gets or sets a value indicating whether access keys are shown in the window. /// Gets or sets a value indicating whether access keys are shown in the window.
/// </summary> /// </summary>

11
src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml.cs

@ -19,8 +19,10 @@ namespace Avalonia.Diagnostics.Views
internal class MainWindow : Window, IStyleHost internal class MainWindow : Window, IStyleHost
{ {
private readonly IDisposable? _keySubscription; private readonly IDisposable? _keySubscription;
private readonly IDisposable? _pointerSubscription;
private readonly Dictionary<Popup, IDisposable> _frozenPopupStates; private readonly Dictionary<Popup, IDisposable> _frozenPopupStates;
private AvaloniaObject? _root; private AvaloniaObject? _root;
private PixelPoint _lastPointerPosition;
public MainWindow() public MainWindow()
{ {
@ -30,6 +32,10 @@ namespace Avalonia.Diagnostics.Views
.OfType<RawKeyEventArgs>() .OfType<RawKeyEventArgs>()
.Where(x => x.Type == RawKeyEventType.KeyDown) .Where(x => x.Type == RawKeyEventType.KeyDown)
.Subscribe(RawKeyDown); .Subscribe(RawKeyDown);
_pointerSubscription = InputManager.Instance?.Process
.OfType<RawPointerEventArgs>()
.Subscribe(x => _lastPointerPosition = x.Root.PointToScreen(x.Position));
_frozenPopupStates = new Dictionary<Popup, IDisposable>(); _frozenPopupStates = new Dictionary<Popup, IDisposable>();
@ -84,6 +90,7 @@ namespace Avalonia.Diagnostics.Views
{ {
base.OnClosed(e); base.OnClosed(e);
_keySubscription?.Dispose(); _keySubscription?.Dispose();
_pointerSubscription?.Dispose();
foreach (var state in _frozenPopupStates) foreach (var state in _frozenPopupStates)
{ {
@ -108,9 +115,7 @@ namespace Avalonia.Diagnostics.Views
private IControl? GetHoveredControl(TopLevel topLevel) private IControl? GetHoveredControl(TopLevel topLevel)
{ {
#pragma warning disable CS0618 // Type or member is obsolete var point = topLevel.PointToClient(_lastPointerPosition);
var point = (topLevel as IInputRoot)?.MouseDevice?.GetPosition(topLevel) ?? default;
#pragma warning restore CS0618 // Type or member is obsolete
return (IControl?)topLevel.GetVisualsAt(point, x => return (IControl?)topLevel.GetVisualsAt(point, x =>
{ {

4
src/Avalonia.OpenGL/Angle/AngleWin32EglDisplay.cs

@ -21,7 +21,7 @@ namespace Avalonia.OpenGL.Angle
var display = IntPtr.Zero; var display = IntPtr.Zero;
AngleOptions.PlatformApi angleApi = default; AngleOptions.PlatformApi angleApi = default;
{ {
if (_egl.GetPlatformDisplayEXT == null) if (!_egl.IsGetPlatformDisplayExtAvailable)
throw new OpenGlException("eglGetPlatformDisplayEXT is not supported by libegl.dll"); throw new OpenGlException("eglGetPlatformDisplayEXT is not supported by libegl.dll");
var allowedApis = AvaloniaLocator.Current.GetService<AngleOptions>()?.AllowedPlatformApis var allowedApis = AvaloniaLocator.Current.GetService<AngleOptions>()?.AllowedPlatformApis
@ -37,7 +37,7 @@ namespace Avalonia.OpenGL.Angle
else else
continue; continue;
display = _egl.GetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, IntPtr.Zero, display = _egl.GetPlatformDisplayExt(EGL_PLATFORM_ANGLE_ANGLE, IntPtr.Zero,
new[] { EGL_PLATFORM_ANGLE_TYPE_ANGLE, dapi, EGL_NONE }); new[] { EGL_PLATFORM_ANGLE_TYPE_ANGLE, dapi, EGL_NONE });
if (display != IntPtr.Zero) if (display != IntPtr.Zero)
{ {

1
src/Avalonia.OpenGL/Avalonia.OpenGL.csproj

@ -11,4 +11,5 @@
</ItemGroup> </ItemGroup>
<Import Project="..\..\build\DevAnalyzers.props" /> <Import Project="..\..\build\DevAnalyzers.props" />
<Import Project="..\..\build\SourceGenerators.props" />
</Project> </Project>

14
src/Avalonia.OpenGL/Controls/OpenGlControlBase.cs

@ -66,11 +66,9 @@ namespace Avalonia.OpenGL.Controls
return; return;
gl.GetIntegerv(GL_RENDERBUFFER_BINDING, out var oldRenderBuffer); gl.GetIntegerv(GL_RENDERBUFFER_BINDING, out var oldRenderBuffer);
if (_depthBuffer != 0) gl.DeleteRenderbuffers(1, new[] { _depthBuffer }); if (_depthBuffer != 0) gl.DeleteRenderbuffer(_depthBuffer);
var oneArr = new int[1]; _depthBuffer = gl.GenRenderbuffer();
gl.GenRenderbuffers(1, oneArr);
_depthBuffer = oneArr[0];
gl.BindRenderbuffer(GL_RENDERBUFFER, _depthBuffer); gl.BindRenderbuffer(GL_RENDERBUFFER, _depthBuffer);
gl.RenderbufferStorage(GL_RENDERBUFFER, gl.RenderbufferStorage(GL_RENDERBUFFER,
GlVersion.Type == GlProfileType.OpenGLES ? GL_DEPTH_COMPONENT16 : GL_DEPTH_COMPONENT, GlVersion.Type == GlProfileType.OpenGLES ? GL_DEPTH_COMPONENT16 : GL_DEPTH_COMPONENT,
@ -88,9 +86,9 @@ namespace Avalonia.OpenGL.Controls
var gl = _context.GlInterface; var gl = _context.GlInterface;
gl.BindTexture(GL_TEXTURE_2D, 0); gl.BindTexture(GL_TEXTURE_2D, 0);
gl.BindFramebuffer(GL_FRAMEBUFFER, 0); gl.BindFramebuffer(GL_FRAMEBUFFER, 0);
gl.DeleteFramebuffers(1, new[] { _fb }); gl.DeleteFramebuffer(_fb);
_fb = 0; _fb = 0;
gl.DeleteRenderbuffers(1, new[] { _depthBuffer }); gl.DeleteRenderbuffer(_depthBuffer);
_depthBuffer = 0; _depthBuffer = 0;
_attachment?.Dispose(); _attachment?.Dispose();
_attachment = null; _attachment = null;
@ -174,9 +172,7 @@ namespace Avalonia.OpenGL.Controls
{ {
_depthBufferSize = GetPixelSize(); _depthBufferSize = GetPixelSize();
var gl = _context.GlInterface; var gl = _context.GlInterface;
var oneArr = new int[1]; _fb = gl.GenFramebuffer();
gl.GenFramebuffers(1, oneArr);
_fb = oneArr[0];
gl.BindFramebuffer(GL_FRAMEBUFFER, _fb); gl.BindFramebuffer(GL_FRAMEBUFFER, _fb);
EnsureDepthBufferAttachment(gl); EnsureDepthBufferAttachment(gl);

376
src/Avalonia.OpenGL/Egl/EglConsts.cs

@ -4,212 +4,212 @@ namespace Avalonia.OpenGL.Egl
{ {
public static class EglConsts public static class EglConsts
{ {
public const int EGL_ALPHA_SIZE = 0x3021; public const int EGL_ALPHA_SIZE = 0x3021;
public const int EGL_BAD_ACCESS = 0x3002; public const int EGL_BAD_ACCESS = 0x3002;
public const int EGL_BAD_ALLOC = 0x3003; public const int EGL_BAD_ALLOC = 0x3003;
public const int EGL_BAD_ATTRIBUTE = 0x3004; public const int EGL_BAD_ATTRIBUTE = 0x3004;
public const int EGL_BAD_CONFIG = 0x3005; public const int EGL_BAD_CONFIG = 0x3005;
public const int EGL_BAD_CONTEXT = 0x3006; public const int EGL_BAD_CONTEXT = 0x3006;
public const int EGL_BAD_CURRENT_SURFACE = 0x3007; public const int EGL_BAD_CURRENT_SURFACE = 0x3007;
public const int EGL_BAD_DISPLAY = 0x3008; public const int EGL_BAD_DISPLAY = 0x3008;
public const int EGL_BAD_MATCH = 0x3009; public const int EGL_BAD_MATCH = 0x3009;
public const int EGL_BAD_NATIVE_PIXMAP = 0x300A; public const int EGL_BAD_NATIVE_PIXMAP = 0x300A;
public const int EGL_BAD_NATIVE_WINDOW = 0x300B; public const int EGL_BAD_NATIVE_WINDOW = 0x300B;
public const int EGL_BAD_PARAMETER = 0x300C; public const int EGL_BAD_PARAMETER = 0x300C;
public const int EGL_BAD_SURFACE = 0x300D; public const int EGL_BAD_SURFACE = 0x300D;
public const int EGL_BLUE_SIZE = 0x3022; public const int EGL_BLUE_SIZE = 0x3022;
public const int EGL_BUFFER_SIZE = 0x3020; // public const int EGL_BUFFER_SIZE = 0x3020;
public const int EGL_CONFIG_CAVEAT = 0x3027; // public const int EGL_CONFIG_CAVEAT = 0x3027;
public const int EGL_CONFIG_ID = 0x3028; // public const int EGL_CONFIG_ID = 0x3028;
public const int EGL_CORE_NATIVE_ENGINE = 0x305B; public const int EGL_CORE_NATIVE_ENGINE = 0x305B;
public const int EGL_DEPTH_SIZE = 0x3025; public const int EGL_DEPTH_SIZE = 0x3025;
public const int EGL_DONT_CARE = -1; // public const int EGL_DONT_CARE = -1;
public const int EGL_DRAW = 0x3059; public const int EGL_DRAW = 0x3059;
public const int EGL_EXTENSIONS = 0x3055; public const int EGL_EXTENSIONS = 0x3055;
public const int EGL_FALSE = 0; public const int EGL_FALSE = 0;
public const int EGL_GREEN_SIZE = 0x3023; public const int EGL_GREEN_SIZE = 0x3023;
public const int EGL_HEIGHT = 0x3056; public const int EGL_HEIGHT = 0x3056;
public const int EGL_LARGEST_PBUFFER = 0x3058; // public const int EGL_LARGEST_PBUFFER = 0x3058;
public const int EGL_LEVEL = 0x3029; // public const int EGL_LEVEL = 0x3029;
public const int EGL_MAX_PBUFFER_HEIGHT = 0x302A; // public const int EGL_MAX_PBUFFER_HEIGHT = 0x302A;
public const int EGL_MAX_PBUFFER_PIXELS = 0x302B; // public const int EGL_MAX_PBUFFER_PIXELS = 0x302B;
public const int EGL_MAX_PBUFFER_WIDTH = 0x302C; // public const int EGL_MAX_PBUFFER_WIDTH = 0x302C;
public const int EGL_NATIVE_RENDERABLE = 0x302D; // public const int EGL_NATIVE_RENDERABLE = 0x302D;
public const int EGL_NATIVE_VISUAL_ID = 0x302E; // public const int EGL_NATIVE_VISUAL_ID = 0x302E;
public const int EGL_NATIVE_VISUAL_TYPE = 0x302F; // public const int EGL_NATIVE_VISUAL_TYPE = 0x302F;
public const int EGL_NONE = 0x3038; public const int EGL_NONE = 0x3038;
public const int EGL_NON_CONFORMANT_CONFIG = 0x3051; // public const int EGL_NON_CONFORMANT_CONFIG = 0x3051;
public const int EGL_NOT_INITIALIZED = 0x3001; public const int EGL_NOT_INITIALIZED = 0x3001;
public const int EGL_NO_CONTEXT = 0; public const int EGL_NO_CONTEXT = 0;
public const int EGL_NO_DISPLAY = 0; public const int EGL_NO_DISPLAY = 0;
public const int EGL_NO_SURFACE = 0; public const int EGL_NO_SURFACE = 0;
public const int EGL_PBUFFER_BIT = 0x0001; public const int EGL_PBUFFER_BIT = 0x0001;
public const int EGL_PIXMAP_BIT = 0x0002; // public const int EGL_PIXMAP_BIT = 0x0002;
public const int EGL_READ = 0x305A; public const int EGL_READ = 0x305A;
public const int EGL_RED_SIZE = 0x3024; public const int EGL_RED_SIZE = 0x3024;
public const int EGL_SAMPLES = 0x3031; public const int EGL_SAMPLES = 0x3031;
public const int EGL_SAMPLE_BUFFERS = 0x3032; // public const int EGL_SAMPLE_BUFFERS = 0x3032;
public const int EGL_SLOW_CONFIG = 0x3050; // public const int EGL_SLOW_CONFIG = 0x3050;
public const int EGL_STENCIL_SIZE = 0x3026; public const int EGL_STENCIL_SIZE = 0x3026;
public const int EGL_SUCCESS = 0x3000; public const int EGL_SUCCESS = 0x3000;
public const int EGL_SURFACE_TYPE = 0x3033; public const int EGL_SURFACE_TYPE = 0x3033;
public const int EGL_TRANSPARENT_BLUE_VALUE = 0x3035; // public const int EGL_TRANSPARENT_BLUE_VALUE = 0x3035;
public const int EGL_TRANSPARENT_GREEN_VALUE = 0x3036; // public const int EGL_TRANSPARENT_GREEN_VALUE = 0x3036;
public const int EGL_TRANSPARENT_RED_VALUE = 0x3037; // public const int EGL_TRANSPARENT_RED_VALUE = 0x3037;
public const int EGL_TRANSPARENT_RGB = 0x3052; // public const int EGL_TRANSPARENT_RGB = 0x3052;
public const int EGL_TRANSPARENT_TYPE = 0x3034; // public const int EGL_TRANSPARENT_TYPE = 0x3034;
public const int EGL_TRUE = 1; public const int EGL_TRUE = 1;
public const int EGL_VENDOR = 0x3053; // public const int EGL_VENDOR = 0x3053;
public const int EGL_VERSION = 0x3054; // public const int EGL_VERSION = 0x3054;
public const int EGL_WIDTH = 0x3057; public const int EGL_WIDTH = 0x3057;
public const int EGL_WINDOW_BIT = 0x0004; public const int EGL_WINDOW_BIT = 0x0004;
public const int EGL_BACK_BUFFER = 0x3084; // public const int EGL_BACK_BUFFER = 0x3084;
public const int EGL_BIND_TO_TEXTURE_RGB = 0x3039; // public const int EGL_BIND_TO_TEXTURE_RGB = 0x3039;
public const int EGL_BIND_TO_TEXTURE_RGBA = 0x303A; // public const int EGL_BIND_TO_TEXTURE_RGBA = 0x303A;
public const int EGL_CONTEXT_LOST = 0x300E; public const int EGL_CONTEXT_LOST = 0x300E;
public const int EGL_MIN_SWAP_INTERVAL = 0x303B; // public const int EGL_MIN_SWAP_INTERVAL = 0x303B;
public const int EGL_MAX_SWAP_INTERVAL = 0x303C; // public const int EGL_MAX_SWAP_INTERVAL = 0x303C;
public const int EGL_MIPMAP_TEXTURE = 0x3082; // public const int EGL_MIPMAP_TEXTURE = 0x3082;
public const int EGL_MIPMAP_LEVEL = 0x3083; // public const int EGL_MIPMAP_LEVEL = 0x3083;
public const int EGL_NO_TEXTURE = 0x305C; // public const int EGL_NO_TEXTURE = 0x305C;
public const int EGL_TEXTURE_2D = 0x305F; // public const int EGL_TEXTURE_2D = 0x305F;
public const int EGL_TEXTURE_FORMAT = 0x3080; // public const int EGL_TEXTURE_FORMAT = 0x3080;
public const int EGL_TEXTURE_RGB = 0x305D; // public const int EGL_TEXTURE_RGB = 0x305D;
public const int EGL_TEXTURE_RGBA = 0x305E; // public const int EGL_TEXTURE_RGBA = 0x305E;
public const int EGL_TEXTURE_TARGET = 0x3081; // public const int EGL_TEXTURE_TARGET = 0x3081;
public const int EGL_ALPHA_FORMAT = 0x3088; // public const int EGL_ALPHA_FORMAT = 0x3088;
public const int EGL_ALPHA_FORMAT_NONPRE = 0x308B; // public const int EGL_ALPHA_FORMAT_NONPRE = 0x308B;
public const int EGL_ALPHA_FORMAT_PRE = 0x308C; // public const int EGL_ALPHA_FORMAT_PRE = 0x308C;
public const int EGL_ALPHA_MASK_SIZE = 0x303E; // public const int EGL_ALPHA_MASK_SIZE = 0x303E;
public const int EGL_BUFFER_PRESERVED = 0x3094; // public const int EGL_BUFFER_PRESERVED = 0x3094;
public const int EGL_BUFFER_DESTROYED = 0x3095; // public const int EGL_BUFFER_DESTROYED = 0x3095;
public const int EGL_CLIENT_APIS = 0x308D; // public const int EGL_CLIENT_APIS = 0x308D;
public const int EGL_COLORSPACE = 0x3087; // public const int EGL_COLORSPACE = 0x3087;
public const int EGL_COLORSPACE_sRGB = 0x3089; // public const int EGL_COLORSPACE_sRGB = 0x3089;
public const int EGL_COLORSPACE_LINEAR = 0x308A; // public const int EGL_COLORSPACE_LINEAR = 0x308A;
public const int EGL_COLOR_BUFFER_TYPE = 0x303F; // public const int EGL_COLOR_BUFFER_TYPE = 0x303F;
public const int EGL_CONTEXT_CLIENT_TYPE = 0x3097; // public const int EGL_CONTEXT_CLIENT_TYPE = 0x3097;
public const int EGL_DISPLAY_SCALING = 10000; // public const int EGL_DISPLAY_SCALING = 10000;
public const int EGL_HORIZONTAL_RESOLUTION = 0x3090; // public const int EGL_HORIZONTAL_RESOLUTION = 0x3090;
public const int EGL_LUMINANCE_BUFFER = 0x308F; // public const int EGL_LUMINANCE_BUFFER = 0x308F;
public const int EGL_LUMINANCE_SIZE = 0x303D; // public const int EGL_LUMINANCE_SIZE = 0x303D;
public const int EGL_OPENGL_ES_BIT = 0x0001; public const int EGL_OPENGL_ES_BIT = 0x0001;
public const int EGL_OPENVG_BIT = 0x0002; // public const int EGL_OPENVG_BIT = 0x0002;
public const int EGL_OPENGL_ES_API = 0x30A0; public const int EGL_OPENGL_ES_API = 0x30A0;
public const int EGL_OPENVG_API = 0x30A1; // public const int EGL_OPENVG_API = 0x30A1;
public const int EGL_OPENVG_IMAGE = 0x3096; // public const int EGL_OPENVG_IMAGE = 0x3096;
public const int EGL_PIXEL_ASPECT_RATIO = 0x3092; // public const int EGL_PIXEL_ASPECT_RATIO = 0x3092;
public const int EGL_RENDERABLE_TYPE = 0x3040; public const int EGL_RENDERABLE_TYPE = 0x3040;
public const int EGL_RENDER_BUFFER = 0x3086; // public const int EGL_RENDER_BUFFER = 0x3086;
public const int EGL_RGB_BUFFER = 0x308E; // public const int EGL_RGB_BUFFER = 0x308E;
public const int EGL_SINGLE_BUFFER = 0x3085; // public const int EGL_SINGLE_BUFFER = 0x3085;
public const int EGL_SWAP_BEHAVIOR = 0x3093; // public const int EGL_SWAP_BEHAVIOR = 0x3093;
public const int EGL_UNKNOWN = -1; // public const int EGL_UNKNOWN = -1;
public const int EGL_VERTICAL_RESOLUTION = 0x3091; // public const int EGL_VERTICAL_RESOLUTION = 0x3091;
public const int EGL_CONFORMANT = 0x3042; // public const int EGL_CONFORMANT = 0x3042;
public const int EGL_CONTEXT_CLIENT_VERSION = 0x3098; // public const int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
public const int EGL_MATCH_NATIVE_PIXMAP = 0x3041; // public const int EGL_MATCH_NATIVE_PIXMAP = 0x3041;
public const int EGL_OPENGL_ES2_BIT = 0x0004; public const int EGL_OPENGL_ES2_BIT = 0x0004;
public const int EGL_VG_ALPHA_FORMAT = 0x3088; // public const int EGL_VG_ALPHA_FORMAT = 0x3088;
public const int EGL_VG_ALPHA_FORMAT_NONPRE = 0x308B; // public const int EGL_VG_ALPHA_FORMAT_NONPRE = 0x308B;
public const int EGL_VG_ALPHA_FORMAT_PRE = 0x308C; // public const int EGL_VG_ALPHA_FORMAT_PRE = 0x308C;
public const int EGL_VG_ALPHA_FORMAT_PRE_BIT = 0x0040; // public const int EGL_VG_ALPHA_FORMAT_PRE_BIT = 0x0040;
public const int EGL_VG_COLORSPACE = 0x3087; // public const int EGL_VG_COLORSPACE = 0x3087;
public const int EGL_VG_COLORSPACE_sRGB = 0x3089; // public const int EGL_VG_COLORSPACE_sRGB = 0x3089;
public const int EGL_VG_COLORSPACE_LINEAR = 0x308A; // public const int EGL_VG_COLORSPACE_LINEAR = 0x308A;
public const int EGL_VG_COLORSPACE_LINEAR_BIT = 0x0020; // public const int EGL_VG_COLORSPACE_LINEAR_BIT = 0x0020;
public const int EGL_DEFAULT_DISPLAY = 0; // public const int EGL_DEFAULT_DISPLAY = 0;
public const int EGL_MULTISAMPLE_RESOLVE_BOX_BIT = 0x0200; // public const int EGL_MULTISAMPLE_RESOLVE_BOX_BIT = 0x0200;
public const int EGL_MULTISAMPLE_RESOLVE = 0x3099; // public const int EGL_MULTISAMPLE_RESOLVE = 0x3099;
public const int EGL_MULTISAMPLE_RESOLVE_DEFAULT = 0x309A; // public const int EGL_MULTISAMPLE_RESOLVE_DEFAULT = 0x309A;
public const int EGL_MULTISAMPLE_RESOLVE_BOX = 0x309B; // public const int EGL_MULTISAMPLE_RESOLVE_BOX = 0x309B;
public const int EGL_OPENGL_API = 0x30A2; // public const int EGL_OPENGL_API = 0x30A2;
public const int EGL_OPENGL_BIT = 0x0008; // public const int EGL_OPENGL_BIT = 0x0008;
public const int EGL_SWAP_BEHAVIOR_PRESERVED_BIT = 0x0400; // public const int EGL_SWAP_BEHAVIOR_PRESERVED_BIT = 0x0400;
public const int EGL_CONTEXT_MAJOR_VERSION = 0x3098; public const int EGL_CONTEXT_MAJOR_VERSION = 0x3098;
public const int EGL_CONTEXT_MINOR_VERSION = 0x30FB; public const int EGL_CONTEXT_MINOR_VERSION = 0x30FB;
public const int EGL_CONTEXT_OPENGL_PROFILE_MASK = 0x30FD; // public const int EGL_CONTEXT_OPENGL_PROFILE_MASK = 0x30FD;
public const int EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY = 0x31BD; // public const int EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY = 0x31BD;
public const int EGL_NO_RESET_NOTIFICATION = 0x31BE; // public const int EGL_NO_RESET_NOTIFICATION = 0x31BE;
public const int EGL_LOSE_CONTEXT_ON_RESET = 0x31BF; // public const int EGL_LOSE_CONTEXT_ON_RESET = 0x31BF;
public const int EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT = 0x00000001; // public const int EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT = 0x00000001;
public const int EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT = 0x00000002; // public const int EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT = 0x00000002;
public const int EGL_CONTEXT_OPENGL_DEBUG = 0x31B0; // public const int EGL_CONTEXT_OPENGL_DEBUG = 0x31B0;
public const int EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE = 0x31B1; // public const int EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE = 0x31B1;
public const int EGL_CONTEXT_OPENGL_ROBUST_ACCESS = 0x31B2; // public const int EGL_CONTEXT_OPENGL_ROBUST_ACCESS = 0x31B2;
public const int EGL_OPENGL_ES3_BIT = 0x00000040; public const int EGL_OPENGL_ES3_BIT = 0x00000040;
public const int EGL_CL_EVENT_HANDLE = 0x309C; // public const int EGL_CL_EVENT_HANDLE = 0x309C;
public const int EGL_SYNC_CL_EVENT = 0x30FE; // public const int EGL_SYNC_CL_EVENT = 0x30FE;
public const int EGL_SYNC_CL_EVENT_COMPLETE = 0x30FF; // public const int EGL_SYNC_CL_EVENT_COMPLETE = 0x30FF;
public const int EGL_SYNC_PRIOR_COMMANDS_COMPLETE = 0x30F0; // public const int EGL_SYNC_PRIOR_COMMANDS_COMPLETE = 0x30F0;
public const int EGL_SYNC_TYPE = 0x30F7; // public const int EGL_SYNC_TYPE = 0x30F7;
public const int EGL_SYNC_STATUS = 0x30F1; // public const int EGL_SYNC_STATUS = 0x30F1;
public const int EGL_SYNC_CONDITION = 0x30F8; // public const int EGL_SYNC_CONDITION = 0x30F8;
public const int EGL_SIGNALED = 0x30F2; // public const int EGL_SIGNALED = 0x30F2;
public const int EGL_UNSIGNALED = 0x30F3; // public const int EGL_UNSIGNALED = 0x30F3;
public const int EGL_SYNC_FLUSH_COMMANDS_BIT = 0x0001; // public const int EGL_SYNC_FLUSH_COMMANDS_BIT = 0x0001;
public const int EGL_TIMEOUT_EXPIRED = 0x30F5; // public const int EGL_TIMEOUT_EXPIRED = 0x30F5;
public const int EGL_CONDITION_SATISFIED = 0x30F6; // public const int EGL_CONDITION_SATISFIED = 0x30F6;
public const int EGL_NO_SYNC = 0; // public const int EGL_NO_SYNC = 0;
public const int EGL_SYNC_FENCE = 0x30F9; // public const int EGL_SYNC_FENCE = 0x30F9;
public const int EGL_GL_COLORSPACE = 0x309D; // public const int EGL_GL_COLORSPACE = 0x309D;
public const int EGL_GL_COLORSPACE_SRGB = 0x3089; // public const int EGL_GL_COLORSPACE_SRGB = 0x3089;
public const int EGL_GL_COLORSPACE_LINEAR = 0x308A; // public const int EGL_GL_COLORSPACE_LINEAR = 0x308A;
public const int EGL_GL_RENDERBUFFER = 0x30B9; // public const int EGL_GL_RENDERBUFFER = 0x30B9;
public const int EGL_GL_TEXTURE_2D = 0x30B1; // public const int EGL_GL_TEXTURE_2D = 0x30B1;
public const int EGL_GL_TEXTURE_LEVEL = 0x30BC; // public const int EGL_GL_TEXTURE_LEVEL = 0x30BC;
public const int EGL_GL_TEXTURE_3D = 0x30B2; // public const int EGL_GL_TEXTURE_3D = 0x30B2;
public const int EGL_GL_TEXTURE_ZOFFSET = 0x30BD; // public const int EGL_GL_TEXTURE_ZOFFSET = 0x30BD;
public const int EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x30B3; // public const int EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x30B3;
public const int EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 0x30B4; // public const int EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 0x30B4;
public const int EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 0x30B5; // public const int EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 0x30B5;
public const int EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x30B6; // public const int EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x30B6;
public const int EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 0x30B7; // public const int EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 0x30B7;
public const int EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x30B8; // public const int EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x30B8;
public const int EGL_IMAGE_PRESERVED = 0x30D2; // public const int EGL_IMAGE_PRESERVED = 0x30D2;
public const int EGL_NO_IMAGE = 0; // public const int EGL_NO_IMAGE = 0;
public const int EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE = 0x3207; public const int EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE = 0x3207;
public const int EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE = 0x3208; public const int EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE = 0x3208;
//EGL_ANGLE_platform_angle //EGL_ANGLE_platform_angle
public const int EGL_PLATFORM_ANGLE_ANGLE = 0x3202; public const int EGL_PLATFORM_ANGLE_ANGLE = 0x3202;
public const int EGL_PLATFORM_ANGLE_TYPE_ANGLE = 0x3203; public const int EGL_PLATFORM_ANGLE_TYPE_ANGLE = 0x3203;
public const int EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE = 0x3204; // public const int EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE = 0x3204;
public const int EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE = 0x3205; // public const int EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE = 0x3205;
public const int EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED = 0x3451; // public const int EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED = 0x3451;
public const int EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE = 0x3206; // public const int EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE = 0x3206;
public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE = 0x320A; // public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE = 0x320A;
public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE = 0x345E; // public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE = 0x345E;
public const int EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE = 0x320D; // public const int EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE = 0x320D;
public const int EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE = 0x320E; // public const int EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE = 0x320E;
//EGL_ANGLE_platform_angle_d3d //EGL_ANGLE_platform_angle_d3d
public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE = 0x3209; // public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE = 0x3209;
public const int EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE = 0x320F; // public const int EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE = 0x320F;
public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_D3D_WARP_ANGLE = 0x320B; // public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_D3D_WARP_ANGLE = 0x320B;
public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_D3D_REFERENCE_ANGLE = 0x320C; // public const int EGL_PLATFORM_ANGLE_DEVICE_TYPE_D3D_REFERENCE_ANGLE = 0x320C;
//EXT_device_query //EXT_device_query
public const int EGL_DEVICE_EXT = 0x322C; public const int EGL_DEVICE_EXT = 0x322C;
//ANGLE_device_d3d //ANGLE_device_d3d
public const int EGL_D3D9_DEVICE_ANGLE = 0x33A0; public const int EGL_D3D9_DEVICE_ANGLE = 0x33A0;
public const int EGL_D3D11_DEVICE_ANGLE = 0x33A1; public const int EGL_D3D11_DEVICE_ANGLE = 0x33A1;
public const int EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE = 0x3200; public const int EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE = 0x3200;
public const int EGL_D3D_TEXTURE_ANGLE = 0x33A3; public const int EGL_D3D_TEXTURE_ANGLE = 0x33A3;
public const int EGL_TEXTURE_OFFSET_X_ANGLE = 0x3490; public const int EGL_TEXTURE_OFFSET_X_ANGLE = 0x3490;
public const int EGL_TEXTURE_OFFSET_Y_ANGLE = 0x3491; public const int EGL_TEXTURE_OFFSET_Y_ANGLE = 0x3491;
public const int EGL_FLEXIBLE_SURFACE_COMPATIBILITY_SUPPORTED_ANGLE = 0x33A6; public const int EGL_FLEXIBLE_SURFACE_COMPATIBILITY_SUPPORTED_ANGLE = 0x33A6;
} }
} }

2
src/Avalonia.OpenGL/Egl/EglContext.cs

@ -24,7 +24,7 @@ namespace Avalonia.OpenGL.Egl
SampleCount = sampleCount; SampleCount = sampleCount;
StencilSize = stencilSize; StencilSize = stencilSize;
using (MakeCurrent()) using (MakeCurrent())
GlInterface = GlInterface.FromNativeUtf8GetProcAddress(version, b => _egl.GetProcAddress(b)); GlInterface = GlInterface.FromNativeUtf8GetProcAddress(version, _egl.GetProcAddress);
} }
public IntPtr Context { get; } public IntPtr Context { get; }

4
src/Avalonia.OpenGL/Egl/EglDisplay.cs

@ -34,9 +34,9 @@ namespace Avalonia.OpenGL.Egl
} }
else else
{ {
if (egl.GetPlatformDisplayEXT == null) if (!egl.IsGetPlatformDisplayExtAvailable)
throw new OpenGlException("eglGetPlatformDisplayEXT is not supported by libegl"); throw new OpenGlException("eglGetPlatformDisplayEXT is not supported by libegl");
display = egl.GetPlatformDisplayEXT(platformType, platformDisplay, attrs); display = egl.GetPlatformDisplayExt(platformType, platformDisplay, attrs);
} }
if (display == IntPtr.Zero) if (display == IntPtr.Zero)

225
src/Avalonia.OpenGL/Egl/EglInterface.cs

@ -2,31 +2,26 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Avalonia.Platform; using Avalonia.Platform;
using Avalonia.Platform.Interop; using Avalonia.Platform.Interop;
using Avalonia.SourceGenerator;
namespace Avalonia.OpenGL.Egl namespace Avalonia.OpenGL.Egl
{ {
public class EglInterface : GlInterfaceBase public unsafe partial class EglInterface
{ {
public EglInterface() : base(Load()) public EglInterface(Func<string, IntPtr> getProcAddress)
{ {
Initialize(getProcAddress);
}
public EglInterface(Func<Utf8Buffer,IntPtr> getProcAddress) : base(getProcAddress)
{
} }
public EglInterface(Func<string, IntPtr> getProcAddress) : base(getProcAddress) public EglInterface(string library) : this(Load(library))
{ {
} }
public EglInterface(string library) : base(Load(library)) public EglInterface() : this(Load())
{ {
} }
static Func<string, IntPtr> Load() static Func<string, IntPtr> Load()
{ {
var os = AvaloniaLocator.Current.GetService<IRuntimePlatform>().GetRuntimeInfo().OperatingSystem; var os = AvaloniaLocator.Current.GetService<IRuntimePlatform>().GetRuntimeInfo().OperatingSystem;
@ -46,119 +41,75 @@ namespace Avalonia.OpenGL.Egl
} }
// ReSharper disable UnassignedGetOnlyAutoProperty // ReSharper disable UnassignedGetOnlyAutoProperty
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate int EglGetError(); [GetProcAddress("eglGetError")]
[GlEntryPoint("eglGetError")] public partial int GetError();
public EglGetError GetError { get; }
[GetProcAddress("eglGetDisplay")]
[UnmanagedFunctionPointer(CallingConvention.StdCall)] public partial IntPtr GetDisplay(IntPtr nativeDisplay);
public delegate IntPtr EglGetDisplay(IntPtr nativeDisplay);
[GlEntryPoint("eglGetDisplay")] [GetProcAddress("eglGetPlatformDisplayEXT", true)]
public EglGetDisplay GetDisplay { get; } public partial IntPtr GetPlatformDisplayExt(int platform, IntPtr nativeDisplay, int[] attrs);
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("eglInitialize")]
public delegate IntPtr EglGetPlatformDisplayEXT(int platform, IntPtr nativeDisplay, int[] attrs); public partial bool Initialize(IntPtr display, out int major, out int minor);
[GlEntryPoint("eglGetPlatformDisplayEXT")]
[GlOptionalEntryPoint] [GetProcAddress("eglGetProcAddress")]
public EglGetPlatformDisplayEXT GetPlatformDisplayEXT { get; } public partial IntPtr GetProcAddress(IntPtr proc);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate bool EglInitialize(IntPtr display, out int major, out int minor);
[GlEntryPoint("eglInitialize")]
public EglInitialize Initialize { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate IntPtr EglGetProcAddress(Utf8Buffer proc);
[GlEntryPoint("eglGetProcAddress")]
public EglGetProcAddress GetProcAddress { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate bool EglBindApi(int api);
[GlEntryPoint("eglBindAPI")]
public EglBindApi BindApi { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate bool EglChooseConfig(IntPtr display, int[] attribs,
out IntPtr surfaceConfig, int numConfigs, out int choosenConfig);
[GlEntryPoint("eglChooseConfig")]
public EglChooseConfig ChooseConfig { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("eglBindAPI")]
public delegate IntPtr EglCreateContext(IntPtr display, IntPtr config, public partial bool BindApi(int api);
[GetProcAddress("eglChooseConfig")]
public partial bool ChooseConfig(IntPtr display, int[] attribs,
out IntPtr surfaceConfig, int numConfigs, out int choosenConfig);
[GetProcAddress("eglCreateContext")]
public partial IntPtr CreateContext(IntPtr display, IntPtr config,
IntPtr share, int[] attrs); IntPtr share, int[] attrs);
[GlEntryPoint("eglCreateContext")]
public EglCreateContext CreateContext { get; } [GetProcAddress("eglDestroyContext")]
public partial bool DestroyContext(IntPtr display, IntPtr context);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate bool EglDestroyContext(IntPtr display, IntPtr context); [GetProcAddress("eglCreatePbufferSurface")]
[GlEntryPoint("eglDestroyContext")] public partial IntPtr CreatePBufferSurface(IntPtr display, IntPtr config, int[] attrs);
public EglDestroyContext DestroyContext { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate IntPtr EglCreatePBufferSurface(IntPtr display, IntPtr config, int[] attrs);
[GlEntryPoint("eglCreatePbufferSurface")]
public EglCreatePBufferSurface CreatePBufferSurface { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate bool EglMakeCurrent(IntPtr display, IntPtr draw, IntPtr read, IntPtr context);
[GlEntryPoint("eglMakeCurrent")]
public EglMakeCurrent MakeCurrent { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate IntPtr EglGetCurrentContext();
[GlEntryPoint("eglGetCurrentContext")]
public EglGetCurrentContext GetCurrentContext { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate IntPtr EglGetCurrentDisplay();
[GlEntryPoint("eglGetCurrentDisplay")]
public EglGetCurrentContext GetCurrentDisplay { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate IntPtr EglGetCurrentSurface(int readDraw);
[GlEntryPoint("eglGetCurrentSurface")]
public EglGetCurrentSurface GetCurrentSurface { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void EglDisplaySurfaceVoidDelegate(IntPtr display, IntPtr surface);
[GlEntryPoint("eglDestroySurface")]
public EglDisplaySurfaceVoidDelegate DestroySurface { get; }
[GlEntryPoint("eglSwapBuffers")]
public EglDisplaySurfaceVoidDelegate SwapBuffers { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate IntPtr
EglCreateWindowSurface(IntPtr display, IntPtr config, IntPtr window, int[] attrs);
[GlEntryPoint("eglCreateWindowSurface")]
public EglCreateWindowSurface CreateWindowSurface { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate bool EglGetConfigAttrib(IntPtr display, IntPtr config, int attr, out int rv);
[GlEntryPoint("eglGetConfigAttrib")]
public EglGetConfigAttrib GetConfigAttrib { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate bool EglWaitGL();
[GlEntryPoint("eglWaitGL")]
public EglWaitGL WaitGL { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate bool EglWaitClient();
[GlEntryPoint("eglWaitClient")]
public EglWaitGL WaitClient { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate bool EglWaitNative(int engine);
[GlEntryPoint("eglWaitNative")]
public EglWaitNative WaitNative { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate IntPtr EglQueryString(IntPtr display, int i);
[GlEntryPoint("eglQueryString")]
public EglQueryString QueryStringNative { get; }
[GetProcAddress("eglMakeCurrent")]
public partial bool MakeCurrent(IntPtr display, IntPtr draw, IntPtr read, IntPtr context);
[GetProcAddress("eglGetCurrentContext")]
public partial IntPtr GetCurrentContext();
[GetProcAddress("eglGetCurrentDisplay")]
public partial IntPtr GetCurrentDisplay();
[GetProcAddress("eglGetCurrentSurface")]
public partial IntPtr GetCurrentSurface(int readDraw);
[GetProcAddress("eglDestroySurface")]
public partial void DestroySurface(IntPtr display, IntPtr surface);
[GetProcAddress("eglSwapBuffers")]
public partial void SwapBuffers(IntPtr display, IntPtr surface);
[GetProcAddress("eglCreateWindowSurface")]
public partial IntPtr CreateWindowSurface(IntPtr display, IntPtr config, IntPtr window, int[] attrs);
[GetProcAddress("eglGetConfigAttrib")]
public partial bool GetConfigAttrib(IntPtr display, IntPtr config, int attr, out int rv);
[GetProcAddress("eglWaitGL")]
public partial bool WaitGL();
[GetProcAddress("eglWaitClient")]
public partial bool WaitClient();
[GetProcAddress("eglWaitNative")]
public partial bool WaitNative(int engine);
[GetProcAddress("eglQueryString")]
public partial IntPtr QueryStringNative(IntPtr display, int i);
public string QueryString(IntPtr display, int i) public string QueryString(IntPtr display, int i)
{ {
var rv = QueryStringNative(display, i); var rv = QueryStringNative(display, i);
@ -166,25 +117,15 @@ namespace Avalonia.OpenGL.Egl
return null; return null;
return Marshal.PtrToStringAnsi(rv); return Marshal.PtrToStringAnsi(rv);
} }
[GetProcAddress("eglCreatePbufferFromClientBuffer")]
public partial IntPtr CreatePbufferFromClientBuffer(IntPtr display, int buftype, IntPtr buffer, IntPtr config, int[] attrib_list);
[GetProcAddress("eglQueryDisplayAttribEXT", true)]
public partial bool QueryDisplayAttribExt(IntPtr display, int attr, out IntPtr res);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate IntPtr EglCreatePbufferFromClientBuffer(IntPtr display, int buftype, IntPtr buffer, IntPtr config, int[] attrib_list); [GetProcAddress("eglQueryDeviceAttribEXT", true)]
[GlEntryPoint("eglCreatePbufferFromClientBuffer")] public partial bool QueryDeviceAttribExt(IntPtr display, int attr, out IntPtr res);
public EglCreatePbufferFromClientBuffer CreatePbufferFromClientBuffer { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate bool EglQueryDisplayAttribEXT(IntPtr display, int attr, out IntPtr res);
[GlEntryPoint("eglQueryDisplayAttribEXT"), GlOptionalEntryPoint]
public EglQueryDisplayAttribEXT QueryDisplayAttribExt { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate bool EglQueryDeviceAttribEXT(IntPtr display, int attr, out IntPtr res);
[GlEntryPoint("eglQueryDeviceAttribEXT"), GlOptionalEntryPoint]
public EglQueryDisplayAttribEXT QueryDeviceAttribExt { get; }
// ReSharper restore UnassignedGetOnlyAutoProperty
} }
} }

44
src/Avalonia.OpenGL/GlBasicInfoInterface.cs

@ -3,46 +3,24 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Avalonia.Platform.Interop; using Avalonia.Platform.Interop;
using Avalonia.SourceGenerator;
namespace Avalonia.OpenGL namespace Avalonia.OpenGL
{ {
public class GlBasicInfoInterface : GlBasicInfoInterface<object> public unsafe partial class GlBasicInfoInterface
{ {
public GlBasicInfoInterface(Func<string, IntPtr> getProcAddress) : base(getProcAddress, null) public GlBasicInfoInterface(Func<string, IntPtr> getProcAddress){
{ Initialize(getProcAddress);
}
public GlBasicInfoInterface(Func<Utf8Buffer, IntPtr> nativeGetProcAddress) : base(nativeGetProcAddress, null)
{
} }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void GlGetIntegerv(int name, out int rv);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate IntPtr GlGetString(int v);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate IntPtr GlGetStringi(int v, int v1);
}
public class GlBasicInfoInterface<TContextInfo> : GlInterfaceBase<TContextInfo> [GetProcAddress("glGetIntegerv")]
{ public partial void GetIntegerv(int name, out int rv);
public GlBasicInfoInterface(Func<string, IntPtr> getProcAddress, TContextInfo context) : base(getProcAddress, context)
{
}
public GlBasicInfoInterface(Func<Utf8Buffer, IntPtr> nativeGetProcAddress, TContextInfo context) : base(nativeGetProcAddress, context) [GetProcAddress("glGetString")]
{ public partial IntPtr GetStringNative(int v);
}
[GetProcAddress("glGetStringi")]
[GlEntryPoint("glGetIntegerv")] public partial IntPtr GetStringiNative(int v, int v1);
public GlBasicInfoInterface.GlGetIntegerv GetIntegerv { get; }
[GlEntryPoint("glGetString")]
public GlBasicInfoInterface.GlGetString GetStringNative { get; }
[GlEntryPoint("glGetStringi")]
public GlBasicInfoInterface.GlGetStringi GetStringiNative { get; }
public string GetString(int v) public string GetString(int v)
{ {

10783
src/Avalonia.OpenGL/GlConsts.cs

File diff suppressed because it is too large

103
src/Avalonia.OpenGL/GlEntryPointAttribute.cs

@ -2,117 +2,54 @@ using System;
namespace Avalonia.OpenGL namespace Avalonia.OpenGL
{ {
public interface IGlEntryPointAttribute [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
class GlMinVersionEntryPoint : Attribute
{ {
IntPtr GetProcAddress(Func<string, IntPtr> getProcAddress); public GlMinVersionEntryPoint(string entry, int minVersionMajor, int minVersionMinor)
}
public interface IGlEntryPointAttribute<in TContext>
{
IntPtr GetProcAddress(TContext context, Func<string, IntPtr> getProcAddress);
}
[AttributeUsage(AttributeTargets.Property)]
public class GlOptionalEntryPoint : Attribute
{
}
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class GlEntryPointAttribute : Attribute, IGlEntryPointAttribute
{
public string[] EntryPoints { get; }
public GlEntryPointAttribute(string entryPoint)
{
EntryPoints = new []{entryPoint};
}
/*
public GlEntryPointAttribute(params string[] entryPoints)
{ {
EntryPoints = entryPoints;
}
*/
public IntPtr GetProcAddress(Func<string, IntPtr> getProcAddress)
{
foreach (var name in EntryPoints)
{
var rv = getProcAddress(name);
if (rv != IntPtr.Zero)
return rv;
}
return IntPtr.Zero;
}
}
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class GlMinVersionEntryPoint : Attribute, IGlEntryPointAttribute<GlInterface.GlContextInfo>
{
private readonly string _entry;
private readonly GlProfileType? _profile;
private readonly int _minVersionMajor;
private readonly int _minVersionMinor;
public GlMinVersionEntryPoint(string entry, GlProfileType profile, int minVersionMajor,
int minVersionMinor)
{
_entry = entry;
_profile = profile;
_minVersionMajor = minVersionMajor;
_minVersionMinor = minVersionMinor;
} }
public GlMinVersionEntryPoint(string entry, int minVersionMajor, public GlMinVersionEntryPoint(string entry, int minVersionMajor, int minVersionMinor, GlProfileType profile)
int minVersionMinor)
{ {
_entry = entry;
_minVersionMajor = minVersionMajor;
_minVersionMinor = minVersionMinor;
} }
public IntPtr GetProcAddress(GlInterface.GlContextInfo context, Func<string, IntPtr> getProcAddress) public static IntPtr GetProcAddress(Func<string, IntPtr> getProcAddress, GlInterface.GlContextInfo context,
string entry, int minVersionMajor, int minVersionMinor, GlProfileType? profile = null)
{ {
if(_profile.HasValue && context.Version.Type != _profile) if(profile.HasValue && context.Version.Type != profile)
return IntPtr.Zero; return IntPtr.Zero;
if(context.Version.Major<_minVersionMajor) if(context.Version.Major<minVersionMajor)
return IntPtr.Zero; return IntPtr.Zero;
if (context.Version.Major == _minVersionMajor && context.Version.Minor < _minVersionMinor) if (context.Version.Major == minVersionMajor && context.Version.Minor < minVersionMinor)
return IntPtr.Zero; return IntPtr.Zero;
return getProcAddress(_entry); return getProcAddress(entry);
} }
} }
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class GlExtensionEntryPoint : Attribute, IGlEntryPointAttribute<GlInterface.GlContextInfo> class GlExtensionEntryPoint : Attribute
{ {
private readonly string _entry; public GlExtensionEntryPoint(string entry, string extension)
private readonly GlProfileType? _profile;
private readonly string _extension;
public GlExtensionEntryPoint(string entry, GlProfileType profile, string extension)
{ {
_entry = entry;
_profile = profile;
_extension = extension;
} }
public GlExtensionEntryPoint(string entry, string extension) public GlExtensionEntryPoint(string entry, string extension, GlProfileType profile)
{ {
_entry = entry;
_extension = extension;
} }
public IntPtr GetProcAddress(GlInterface.GlContextInfo context, Func<string, IntPtr> getProcAddress) public static IntPtr GetProcAddress(Func<string, IntPtr> getProcAddress, GlInterface.GlContextInfo context,
string entry, string extension, GlProfileType? profile = null)
{ {
// Ignore different profile type // Ignore different profile type
if (_profile.HasValue && _profile != context.Version.Type) if (profile.HasValue && profile != context.Version.Type)
return IntPtr.Zero; return IntPtr.Zero;
// Check if extension is supported by the current context // Check if extension is supported by the current context
if (!context.Extensions.Contains(_extension)) if (!context.Extensions.Contains(extension))
return IntPtr.Zero; return IntPtr.Zero;
return getProcAddress(_entry); return getProcAddress(entry);
} }
} }
} }

494
src/Avalonia.OpenGL/GlInterface.cs

@ -3,14 +3,14 @@ using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using Avalonia.Platform.Interop; using Avalonia.Platform.Interop;
using Avalonia.SourceGenerator;
using static Avalonia.OpenGL.GlConsts; using static Avalonia.OpenGL.GlConsts;
namespace Avalonia.OpenGL namespace Avalonia.OpenGL
{ {
public delegate IntPtr GlGetProcAddressDelegate(string procName); public unsafe partial class GlInterface : GlBasicInfoInterface
public unsafe class GlInterface : GlBasicInfoInterface<GlInterface.GlContextInfo>
{ {
private readonly Func<string, IntPtr> _getProcAddress;
public string Version { get; } public string Version { get; }
public string Vendor { get; } public string Vendor { get; }
public string Renderer { get; } public string Renderer { get; }
@ -35,12 +35,14 @@ namespace Avalonia.OpenGL
} }
} }
private GlInterface(GlContextInfo info, Func<string, IntPtr> getProcAddress) : base(getProcAddress, info) private GlInterface(GlContextInfo info, Func<string, IntPtr> getProcAddress) : base(getProcAddress)
{ {
_getProcAddress = getProcAddress;
ContextInfo = info; ContextInfo = info;
Version = GetString(GlConsts.GL_VERSION); Version = GetString(GlConsts.GL_VERSION);
Renderer = GetString(GlConsts.GL_RENDERER); Renderer = GetString(GlConsts.GL_RENDERER);
Vendor = GetString(GlConsts.GL_VENDOR); Vendor = GetString(GlConsts.GL_VENDOR);
Initialize(getProcAddress, ContextInfo);
} }
public GlInterface(GlVersion version, Func<string, IntPtr> getProcAddress) : this( public GlInterface(GlVersion version, Func<string, IntPtr> getProcAddress) : this(
@ -48,92 +50,58 @@ namespace Avalonia.OpenGL
{ {
} }
public GlInterface(GlVersion version, Func<Utf8Buffer, IntPtr> n) : this(version, ConvertNative(n)) public IntPtr GetProcAddress(string proc) => _getProcAddress(proc);
[GetProcAddress("glGetError")]
public partial int GetError();
[GetProcAddress("glClearStencil")]
public partial void ClearStencil(int s);
[GetProcAddress("glClearColor")]
public partial void ClearColor(float r, float g, float b, float a);
[GetProcAddress("glClear")]
public partial void Clear(int bits);
[GetProcAddress("glViewport")]
public partial void Viewport(int x, int y, int width, int height);
[GetProcAddress("glFlush")]
public partial void Flush();
[GetProcAddress("glFinish")]
public partial void Finish();
[GetProcAddress("glGetIntegerv")]
public partial void GetIntegerv(int name, out int rv);
[GetProcAddress("glGenFramebuffers")]
public partial void GenFramebuffers(int count, int* res);
public int GenFramebuffer()
{ {
int rv = 0;
GenFramebuffers(1, &rv);
return rv;
} }
public static GlInterface FromNativeUtf8GetProcAddress(GlVersion version, Func<Utf8Buffer, IntPtr> getProcAddress) => [GetProcAddress("glDeleteFramebuffers")]
new GlInterface(version, getProcAddress); public partial void DeleteFramebuffers(int count, int* framebuffers);
public void DeleteFramebuffer(int fb)
public T GetProcAddress<T>(string proc) => Marshal.GetDelegateForFunctionPointer<T>(GetProcAddress(proc));
// ReSharper disable UnassignedGetOnlyAutoProperty
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate int GlGetError();
[GlEntryPoint("glGetError")]
public GlGetError GetError { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void GlClearStencil(int s);
[GlEntryPoint("glClearStencil")]
public GlClearStencil ClearStencil { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void GlClearColor(float r, float g, float b, float a);
[GlEntryPoint("glClearColor")]
public GlClearColor ClearColor { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void GlClear(int bits);
[GlEntryPoint("glClear")]
public GlClear Clear { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void GlViewport(int x, int y, int width, int height);
[GlEntryPoint("glViewport")]
public GlViewport Viewport { get; }
[GlEntryPoint("glFlush")]
public UnmanagedAction Flush { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void UnmanagedAction();
[GlEntryPoint("glFinish")]
public UnmanagedAction Finish { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate IntPtr GlGetString(int v);
[GlEntryPoint("glGetString")]
public GlGetString GetStringNative { get; }
public string GetString(int v)
{ {
var ptr = GetStringNative(v); DeleteFramebuffers(1, &fb);
if (ptr != IntPtr.Zero)
return Marshal.PtrToStringAnsi(ptr);
return null;
} }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glBindFramebuffer")]
public delegate void GlGetIntegerv(int name, out int rv); public partial void BindFramebuffer(int target, int fb);
[GlEntryPoint("glGetIntegerv")]
public GlGetIntegerv GetIntegerv { get; } [GetProcAddress("glCheckFramebufferStatus")]
public partial int CheckFramebufferStatus(int target);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void GlGenFramebuffers(int count, int[] res); [GlMinVersionEntryPoint("glBlitFramebuffer", 3, 0), GetProcAddress(true)]
[GlEntryPoint("glGenFramebuffers")] public partial void BlitFramebuffer(int srcX0,
public GlGenFramebuffers GenFramebuffers { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void GlDeleteFramebuffers(int count, int[] framebuffers);
[GlEntryPoint("glDeleteFramebuffers")]
public GlDeleteFramebuffers DeleteFramebuffers { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void GlBindFramebuffer(int target, int fb);
[GlEntryPoint("glBindFramebuffer")]
public GlBindFramebuffer BindFramebuffer { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate int GlCheckFramebufferStatus(int target);
[GlEntryPoint("glCheckFramebufferStatus")]
public GlCheckFramebufferStatus CheckFramebufferStatus { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void GlBlitFramebuffer(int srcX0,
int srcY0, int srcY0,
int srcX1, int srcX1,
int srcY1, int srcY1,
@ -143,89 +111,78 @@ namespace Avalonia.OpenGL
int dstY1, int dstY1,
int mask, int mask,
int filter); int filter);
[GlMinVersionEntryPoint("glBlitFramebuffer", 3, 0), GlOptionalEntryPoint]
public GlBlitFramebuffer BlitFramebuffer { get; }
[GetProcAddress("glGenRenderbuffers")]
[UnmanagedFunctionPointer(CallingConvention.StdCall)] public partial void GenRenderbuffers(int count, int* res);
public delegate void GlGenRenderbuffers(int count, int[] res);
[GlEntryPoint("glGenRenderbuffers")] public int GenRenderbuffer()
public GlGenRenderbuffers GenRenderbuffers { get; } {
int rv = 0;
[UnmanagedFunctionPointer(CallingConvention.StdCall)] GenRenderbuffers(1, &rv);
public delegate void GlDeleteRenderbuffers(int count, int[] renderbuffers); return rv;
[GlEntryPoint("glDeleteRenderbuffers")] }
public GlDeleteTextures DeleteRenderbuffers { get; }
[GetProcAddress("glDeleteRenderbuffers")]
[UnmanagedFunctionPointer(CallingConvention.StdCall)] public partial void DeleteRenderbuffers(int count, int* renderbuffers);
public delegate void GlBindRenderbuffer(int target, int fb);
[GlEntryPoint("glBindRenderbuffer")] public void DeleteRenderbuffer(int renderbuffer)
public GlBindRenderbuffer BindRenderbuffer { get; } {
DeleteRenderbuffers(1, &renderbuffer);
[UnmanagedFunctionPointer(CallingConvention.StdCall)] }
public delegate void GlRenderbufferStorage(int target, int internalFormat, int width, int height);
[GlEntryPoint("glRenderbufferStorage")] [GetProcAddress("glBindRenderbuffer")]
public GlRenderbufferStorage RenderbufferStorage { get; } public partial void BindRenderbuffer(int target, int fb);
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glRenderbufferStorage")]
public delegate void GlFramebufferRenderbuffer(int target, int attachment, public partial void RenderbufferStorage(int target, int internalFormat, int width, int height);
[GetProcAddress("glFramebufferRenderbuffer")]
public partial void FramebufferRenderbuffer(int target, int attachment,
int renderbufferTarget, int renderbuffer); int renderbufferTarget, int renderbuffer);
[GlEntryPoint("glFramebufferRenderbuffer")]
public GlFramebufferRenderbuffer FramebufferRenderbuffer { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glGenTextures")]
public delegate void GlGenTextures(int count, int[] res); public partial void GenTextures(int count, int* res);
[GlEntryPoint("glGenTextures")]
public GlGenTextures GenTextures { get; } public int GenTexture()
{
int rv = 0;
GenTextures(1, &rv);
return rv;
}
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glBindTexture")]
public delegate void GlBindTexture(int target, int fb); public partial void BindTexture(int target, int fb);
[GlEntryPoint("glBindTexture")]
public GlBindTexture BindTexture { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glActiveTexture")]
public delegate void GlActiveTexture(int texture); public partial void ActiveTexture(int texture);
[GlEntryPoint("glActiveTexture")]
public GlActiveTexture ActiveTexture { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glDeleteTextures")]
public delegate void GlDeleteTextures(int count, int[] textures); public partial void DeleteTextures(int count, int* textures);
[GlEntryPoint("glDeleteTextures")]
public GlDeleteTextures DeleteTextures { get; }
public void DeleteTexture(int texture) => DeleteTextures(1, &texture);
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glTexImage2D")]
public delegate void GlTexImage2D(int target, int level, int internalFormat, int width, int height, int border, public partial void TexImage2D(int target, int level, int internalFormat, int width, int height, int border,
int format, int type, IntPtr data); int format, int type, IntPtr data);
[GlEntryPoint("glTexImage2D")]
public GlTexImage2D TexImage2D { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glCopyTexSubImage2D")]
public delegate void GlCopyTexSubImage2D(int target, int level, int xoffset, int yoffset, int x, int y, public partial void CopyTexSubImage2D(int target, int level, int xoffset, int yoffset, int x, int y,
int width, int height); int width, int height);
[GlEntryPoint("glCopyTexSubImage2D")]
public GlCopyTexSubImage2D CopyTexSubImage2D { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glTexParameteri")]
public delegate void GlTexParameteri(int target, int name, int value); public partial void TexParameteri(int target, int name, int value);
[GlEntryPoint("glTexParameteri")]
public GlTexParameteri TexParameteri { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void GlFramebufferTexture2D(int target, int attachment, [GetProcAddress("glFramebufferTexture2D")]
public partial void FramebufferTexture2D(int target, int attachment,
int texTarget, int texture, int level); int texTarget, int texture, int level);
[GlEntryPoint("glFramebufferTexture2D")]
public GlFramebufferTexture2D FramebufferTexture2D { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glCreateShader")]
public delegate int GlCreateShader(int shaderType); public partial int CreateShader(int shaderType);
[GlEntryPoint("glCreateShader")]
public GlCreateShader CreateShader { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glShaderSource")]
public delegate void GlShaderSource(int shader, int count, IntPtr strings, IntPtr lengths); public partial void ShaderSource(int shader, int count, IntPtr strings, IntPtr lengths);
[GlEntryPoint("glShaderSource")]
public GlShaderSource ShaderSource { get; }
public void ShaderSourceString(int shader, string source) public void ShaderSourceString(int shader, string source)
{ {
@ -237,20 +194,14 @@ namespace Avalonia.OpenGL
} }
} }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glCompileShader")]
public delegate void GlCompileShader(int shader); public partial void CompileShader(int shader);
[GlEntryPoint("glCompileShader")]
public GlCompileShader CompileShader { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glGetShaderiv")]
public delegate void GlGetShaderiv(int shader, int name, int* parameters); public partial void GetShaderiv(int shader, int name, int* parameters);
[GlEntryPoint("glGetShaderiv")]
public GlGetShaderiv GetShaderiv { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glGetShaderInfoLog")]
public delegate void GlGetShaderInfoLog(int shader, int maxLength, out int length, void*infoLog); public partial void GetShaderInfoLog(int shader, int maxLength, out int length, void* infoLog);
[GlEntryPoint("glGetShaderInfoLog")]
public GlGetShaderInfoLog GetShaderInfoLog { get; }
public unsafe string CompileShaderAndGetError(int shader, string source) public unsafe string CompileShaderAndGetError(int shader, string source)
{ {
@ -268,33 +219,24 @@ namespace Avalonia.OpenGL
int len; int len;
fixed (void* ptr = logData) fixed (void* ptr = logData)
GetShaderInfoLog(shader, logLength, out len, ptr); GetShaderInfoLog(shader, logLength, out len, ptr);
return Encoding.UTF8.GetString(logData,0, len); return Encoding.UTF8.GetString(logData, 0, len);
} }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate int GlCreateProgram();
[GlEntryPoint("glCreateProgram")]
public GlCreateProgram CreateProgram { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glCreateProgram")]
public delegate void GlAttachShader(int program, int shader); public partial int CreateProgram();
[GlEntryPoint("glAttachShader")]
public GlAttachShader AttachShader { get; } [GetProcAddress("glAttachShader")]
public partial void AttachShader(int program, int shader);
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glLinkProgram")]
public delegate void GlLinkProgram(int program); public partial void LinkProgram(int program);
[GlEntryPoint("glLinkProgram")]
public GlLinkProgram LinkProgram { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glGetProgramiv")]
public delegate void GlGetProgramiv(int program, int name, int* parameters); public partial void GetProgramiv(int program, int name, int* parameters);
[GlEntryPoint("glGetProgramiv")]
public GlGetProgramiv GetProgramiv { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glGetProgramInfoLog")]
public delegate void GlGetProgramInfoLog(int program, int maxLength, out int len, void* infoLog); public partial void GetProgramInfoLog(int program, int maxLength, out int len, void* infoLog);
[GlEntryPoint("glGetProgramInfoLog")]
public GlGetProgramInfoLog GetProgramInfoLog { get; }
public unsafe string LinkProgramAndGetError(int program) public unsafe string LinkProgramAndGetError(int program)
{ {
@ -309,13 +251,11 @@ namespace Avalonia.OpenGL
int len; int len;
fixed (void* ptr = logData) fixed (void* ptr = logData)
GetProgramInfoLog(program, logLength, out len, ptr); GetProgramInfoLog(program, logLength, out len, ptr);
return Encoding.UTF8.GetString(logData,0, len); return Encoding.UTF8.GetString(logData, 0, len);
} }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glBindAttribLocation")]
public delegate void GlBindAttribLocation(int program, int index, IntPtr name); public partial void BindAttribLocation(int program, int index, IntPtr name);
[GlEntryPoint("glBindAttribLocation")]
public GlBindAttribLocation BindAttribLocation { get; }
public void BindAttribLocationString(int program, int index, string name) public void BindAttribLocationString(int program, int index, string name)
{ {
@ -323,32 +263,24 @@ namespace Avalonia.OpenGL
BindAttribLocation(program, index, b.DangerousGetHandle()); BindAttribLocation(program, index, b.DangerousGetHandle());
} }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glGenBuffers")]
public delegate void GlGenBuffers(int len, int[] rv); public partial void GenBuffers(int len, int* rv);
[GlEntryPoint("glGenBuffers")]
public GlGenBuffers GenBuffers { get; }
public int GenBuffer() public int GenBuffer()
{ {
var rv = new int[1]; int rv;
GenBuffers(1, rv); GenBuffers(1, &rv);
return rv[0]; return rv;
} }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glBindBuffer")]
public delegate void GlBindBuffer(int target, int buffer); public partial void BindBuffer(int target, int buffer);
[GlEntryPoint("glBindBuffer")]
public GlBindBuffer BindBuffer { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glBufferData")]
public delegate void GlBufferData(int target, IntPtr size, IntPtr data, int usage); public partial void BufferData(int target, IntPtr size, IntPtr data, int usage);
[GlEntryPoint("glBufferData")]
public GlBufferData BufferData { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glGetAttribLocation")]
public delegate int GlGetAttribLocation(int program, IntPtr name); public partial int GetAttribLocation(int program, IntPtr name);
[GlEntryPoint("glGetAttribLocation")]
public GlGetAttribLocation GetAttribLocation { get; }
public int GetAttribLocationString(int program, string name) public int GetAttribLocationString(int program, string name)
{ {
@ -356,36 +288,24 @@ namespace Avalonia.OpenGL
return GetAttribLocation(program, b.DangerousGetHandle()); return GetAttribLocation(program, b.DangerousGetHandle());
} }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glVertexAttribPointer")]
public delegate void GlVertexAttribPointer(int index, int size, int type, public partial void VertexAttribPointer(int index, int size, int type,
int normalized, int stride, IntPtr pointer); int normalized, int stride, IntPtr pointer);
[GlEntryPoint("glVertexAttribPointer")]
public GlVertexAttribPointer VertexAttribPointer { get; } [GetProcAddress("glEnableVertexAttribArray")]
public partial void EnableVertexAttribArray(int index);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void GlEnableVertexAttribArray(int index); [GetProcAddress("glUseProgram")]
[GlEntryPoint("glEnableVertexAttribArray")] public partial void UseProgram(int program);
public GlEnableVertexAttribArray EnableVertexAttribArray { get; }
[GetProcAddress("glDrawArrays")]
[UnmanagedFunctionPointer(CallingConvention.StdCall)] public partial void DrawArrays(int mode, int first, IntPtr count);
public delegate void GlUseProgram(int program);
[GlEntryPoint("glUseProgram")] [GetProcAddress("glDrawElements")]
public GlUseProgram UseProgram { get; } public partial void DrawElements(int mode, int count, int type, IntPtr indices);
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glGetUniformLocation")]
public delegate void GlDrawArrays(int mode, int first, IntPtr count); public partial int GetUniformLocation(int program, IntPtr name);
[GlEntryPoint("glDrawArrays")]
public GlDrawArrays DrawArrays { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void GlDrawElements(int mode, int count, int type, IntPtr indices);
[GlEntryPoint("glDrawElements")]
public GlDrawElements DrawElements { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate int GlGetUniformLocation(int program, IntPtr name);
[GlEntryPoint("glGetUniformLocation")]
public GlGetUniformLocation GetUniformLocation { get; }
public int GetUniformLocationString(int program, string name) public int GetUniformLocationString(int program, string name)
{ {
@ -393,41 +313,65 @@ namespace Avalonia.OpenGL
return GetUniformLocation(program, b.DangerousGetHandle()); return GetUniformLocation(program, b.DangerousGetHandle());
} }
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glUniform1f")]
public delegate void GlUniform1f(int location, float falue); public partial void Uniform1f(int location, float falue);
[GlEntryPoint("glUniform1f")]
public GlUniform1f Uniform1f { get; }
[GetProcAddress("glUniformMatrix4fv")]
public partial void UniformMatrix4fv(int location, int count, bool transpose, void* value);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void GlUniformMatrix4fv(int location, int count, bool transpose, void* value); [GetProcAddress("glEnable")]
[GlEntryPoint("glUniformMatrix4fv")] public partial void Enable(int what);
public GlUniformMatrix4fv UniformMatrix4fv { get; }
[GetProcAddress("glDeleteBuffers")]
[UnmanagedFunctionPointer(CallingConvention.StdCall)] public partial void DeleteBuffers(int count, int* buffers);
public delegate void GlEnable(int what);
[GlEntryPoint("glEnable")] public void DeleteBuffer(int buffer) => DeleteBuffers(1, &buffer);
public GlEnable Enable { get; }
[GetProcAddress("glDeleteProgram")]
[UnmanagedFunctionPointer(CallingConvention.StdCall)] public partial void DeleteProgram(int program);
public delegate void GlDeleteBuffers(int count, int[] buffers);
[GlEntryPoint("glDeleteBuffers")] [GetProcAddress("glDeleteShader")]
public GlDeleteBuffers DeleteBuffers { get; } public partial void DeleteShader(int shader);
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [GetProcAddress("glGetRenderbufferParameteriv")]
public delegate void GlDeleteProgram(int program); public partial void GetRenderbufferParameteriv(int target, int name, out int value);
[GlEntryPoint("glDeleteProgram")]
public GlDeleteProgram DeleteProgram { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void GlDeleteShader(int shader);
[GlEntryPoint("glDeleteShader")]
public GlDeleteShader DeleteShader { get; }
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void GLGetRenderbufferParameteriv(int target, int name, int[] value);
[GlEntryPoint("glGetRenderbufferParameteriv")]
public GLGetRenderbufferParameteriv GetRenderbufferParameteriv { get; }
// ReSharper restore UnassignedGetOnlyAutoProperty // ReSharper restore UnassignedGetOnlyAutoProperty
[GetProcAddress(true)]
[GlMinVersionEntryPoint("glDeleteVertexArrays", 3, 0)]
[GlExtensionEntryPoint("glDeleteVertexArraysOES", "GL_OES_vertex_array_object")]
public partial void DeleteVertexArrays(int count, int* arrays);
public void DeleteVertexArray(int array) => DeleteVertexArrays(1, &array);
[GetProcAddress(true)]
[GlMinVersionEntryPoint("glBindVertexArray", 3, 0)]
[GlExtensionEntryPoint("glBindVertexArrayOES", "GL_OES_vertex_array_object")]
public partial void BindVertexArray(int array);
[GetProcAddress(true)]
[GlMinVersionEntryPoint("glGenVertexArrays", 3, 0)]
[GlExtensionEntryPoint("glGenVertexArraysOES", "GL_OES_vertex_array_object")]
public partial void GenVertexArrays(int n, int* rv);
public int GenVertexArray()
{
int rv = 0;
GenVertexArrays(1, &rv);
return rv;
}
public static GlInterface FromNativeUtf8GetProcAddress(GlVersion version, Func<IntPtr, IntPtr> getProcAddress)
{
return new GlInterface(version, s =>
{
var ptr = Marshal.StringToHGlobalAnsi(s);
var rv = getProcAddress(ptr);
Marshal.FreeHGlobal(ptr);
return rv;
});
}
} }
} }

79
src/Avalonia.OpenGL/GlInterfaceBase.cs

@ -1,79 +0,0 @@
using System;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using Avalonia.Platform.Interop;
namespace Avalonia.OpenGL
{
public class GlInterfaceBase : GlInterfaceBase<object>
{
public GlInterfaceBase(Func<string, IntPtr> getProcAddress) : base(getProcAddress, null)
{
}
public GlInterfaceBase(Func<Utf8Buffer, IntPtr> nativeGetProcAddress) : base(nativeGetProcAddress, null)
{
}
}
public class GlInterfaceBase<TContext>
{
private readonly Func<string, IntPtr> _getProcAddress;
public GlInterfaceBase(Func<string, IntPtr> getProcAddress, TContext context)
{
_getProcAddress = getProcAddress;
foreach (var prop in this.GetType().GetProperties())
{
var attrs = prop.GetCustomAttributes()
.Where(a =>
a is IGlEntryPointAttribute || a is IGlEntryPointAttribute<TContext>)
.ToList();
if(attrs.Count == 0)
continue;
var isOptional = prop.GetCustomAttribute<GlOptionalEntryPoint>() != null;
var fieldName = $"<{prop.Name}>k__BackingField";
var field = prop.DeclaringType.GetField(fieldName,
BindingFlags.Instance | BindingFlags.NonPublic);
if (field == null)
throw new InvalidProgramException($"Expected property {prop.Name} to have {fieldName}");
IntPtr proc = IntPtr.Zero;
foreach (var attr in attrs)
{
if (attr is IGlEntryPointAttribute<TContext> typed)
proc = typed.GetProcAddress(context, getProcAddress);
else if (attr is IGlEntryPointAttribute untyped)
proc = untyped.GetProcAddress(getProcAddress);
if (proc != IntPtr.Zero)
break;
}
if (proc != IntPtr.Zero)
field.SetValue(this, Marshal.GetDelegateForFunctionPointer(proc, prop.PropertyType));
else if (!isOptional)
throw new OpenGlException("Unable to find a suitable GL function for " + prop.Name);
}
}
protected static Func<string, IntPtr> ConvertNative(Func<Utf8Buffer, IntPtr> func) =>
(proc) =>
{
using (var u = new Utf8Buffer(proc))
{
var rv = func(u);
return rv;
}
};
public GlInterfaceBase(Func<Utf8Buffer, IntPtr> nativeGetProcAddress, TContext context) : this(ConvertNative(nativeGetProcAddress), context)
{
}
public IntPtr GetProcAddress(string proc) => _getProcAddress(proc);
}
}

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

@ -308,6 +308,7 @@
<!--Resources for NotificationCard.xaml --> <!--Resources for NotificationCard.xaml -->
<SolidColorBrush x:Key="NotificationCardBackgroundBrush" Color="#444444" /> <SolidColorBrush x:Key="NotificationCardBackgroundBrush" Color="#444444" />
<StaticResource x:Key="NotificationCardForegroundBrush" ResourceKey="SystemControlForegroundBaseHighBrush" />
<SolidColorBrush x:Key="NotificationCardProgressBackgroundBrush" Color="#9A9A9A" /> <SolidColorBrush x:Key="NotificationCardProgressBackgroundBrush" Color="#9A9A9A" />
<SolidColorBrush x:Key="NotificationCardInformationBackgroundBrush" Color="#007ACC" Opacity="0.75"/> <SolidColorBrush x:Key="NotificationCardInformationBackgroundBrush" Color="#007ACC" Opacity="0.75"/>
<SolidColorBrush x:Key="NotificationCardSuccessBackgroundBrush" Color="#1F9E45" Opacity="0.75"/> <SolidColorBrush x:Key="NotificationCardSuccessBackgroundBrush" Color="#1F9E45" Opacity="0.75"/>

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

@ -304,6 +304,7 @@
<!--Resources for NotificationCard.xaml --> <!--Resources for NotificationCard.xaml -->
<SolidColorBrush x:Key="NotificationCardBackgroundBrush" Color="White" /> <SolidColorBrush x:Key="NotificationCardBackgroundBrush" Color="White" />
<StaticResource x:Key="NotificationCardForegroundBrush" ResourceKey="SystemControlForegroundBaseHighBrush" />
<SolidColorBrush x:Key="NotificationCardProgressBackgroundBrush" Color="#9A9A9A" /> <SolidColorBrush x:Key="NotificationCardProgressBackgroundBrush" Color="#9A9A9A" />
<SolidColorBrush x:Key="NotificationCardInformationBackgroundBrush" Color="#0078D4" /> <SolidColorBrush x:Key="NotificationCardInformationBackgroundBrush" Color="#0078D4" />
<SolidColorBrush x:Key="NotificationCardSuccessBackgroundBrush" Color="#128B44" /> <SolidColorBrush x:Key="NotificationCardSuccessBackgroundBrush" Color="#128B44" />

110
src/Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml

@ -1,5 +1,5 @@
<Styles xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith> <Design.PreviewWith>
<Border Padding="20"> <Border Padding="20">
<AutoCompleteBox Width="200"> <AutoCompleteBox Width="200">
@ -16,56 +16,56 @@
</AutoCompleteBox> </AutoCompleteBox>
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Style Selector="AutoCompleteBox"> <ControlTheme x:Key="{x:Type AutoCompleteBox}" TargetType="AutoCompleteBox">
<Setter Property="VerticalAlignment" Value="Top" /> <Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" /> <Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" />
<Setter Property="Background" Value="{DynamicResource TextControlBackground}" /> <Setter Property="Background" Value="{DynamicResource TextControlBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThickness}" /> <Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThickness}" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" /> <Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="Padding" Value="{DynamicResource TextControlThemePadding}" /> <Setter Property="Padding" Value="{DynamicResource TextControlThemePadding}" />
<Setter Property="MaxDropDownHeight" Value="{DynamicResource AutoCompleteListMaxHeight}" /> <Setter Property="MaxDropDownHeight" Value="{DynamicResource AutoCompleteListMaxHeight}" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Grid Name="PART_LayoutRoot"> <Grid Name="PART_LayoutRoot">
<TextBox Name="PART_TextBox" <TextBox Name="PART_TextBox"
Watermark="{TemplateBinding Watermark}" Watermark="{TemplateBinding Watermark}"
Width="{TemplateBinding Width}" Width="{TemplateBinding Width}"
Foreground="{TemplateBinding Foreground}" Foreground="{TemplateBinding Foreground}"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}" CornerRadius="{TemplateBinding CornerRadius}"
FontSize="{TemplateBinding FontSize}" FontSize="{TemplateBinding FontSize}"
FontFamily="{TemplateBinding FontFamily}" FontFamily="{TemplateBinding FontFamily}"
FontWeight="{TemplateBinding FontWeight}" FontWeight="{TemplateBinding FontWeight}"
Padding="{TemplateBinding Padding}" Padding="{TemplateBinding Padding}"
Margin="0" Margin="0"
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" /> DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" />
<Popup Name="PART_Popup"
<Popup Name="PART_Popup" WindowManagerAddShadowHint="False"
WindowManagerAddShadowHint="False" MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}" MaxHeight="{TemplateBinding MaxDropDownHeight}"
MaxHeight="{TemplateBinding MaxDropDownHeight}" IsLightDismissEnabled="True"
IsLightDismissEnabled="True" PlacementTarget="{TemplateBinding}">
PlacementTarget="{TemplateBinding}"> <Border Name="PART_SuggestionsContainer"
<Border Name="PART_SuggestionsContainer" Padding="{DynamicResource AutoCompleteListMargin}"
Padding="{DynamicResource AutoCompleteListMargin}" BorderThickness="{DynamicResource AutoCompleteListBorderThemeThickness}"
BorderThickness="{DynamicResource AutoCompleteListBorderThemeThickness}" BorderBrush="{DynamicResource AutoCompleteBoxSuggestionsListBorderBrush}"
BorderBrush="{DynamicResource AutoCompleteBoxSuggestionsListBorderBrush}" Background="{DynamicResource AutoCompleteBoxSuggestionsListBackground}"
Background="{DynamicResource AutoCompleteBoxSuggestionsListBackground}" CornerRadius="{DynamicResource OverlayCornerRadius}">
CornerRadius="{DynamicResource OverlayCornerRadius}"> <ListBox Name="PART_SelectingItemsControl"
<ListBox Name="PART_SelectingItemsControl" BorderThickness="0"
BorderThickness="0" Background="Transparent"
Background="Transparent" ItemTemplate="{TemplateBinding ItemTemplate}"
ItemTemplate="{TemplateBinding ItemTemplate}" Margin="{DynamicResource AutoCompleteListPadding}" />
Margin="{DynamicResource AutoCompleteListPadding}" /> </Border>
</Border> </Popup>
</Popup> </Grid>
</Grid> </ControlTemplate>
</ControlTemplate> </Setter>
</Setter> </ControlTheme>
</Style>
</Styles> </ResourceDictionary>

43
src/Avalonia.Themes.Fluent/Controls/Button.xaml

@ -1,4 +1,5 @@
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith> <Design.PreviewWith>
<Border Padding="20"> <Border Padding="20">
<StackPanel Spacing="20"> <StackPanel Spacing="20">
@ -7,14 +8,11 @@
</StackPanel> </StackPanel>
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Styles.Resources>
<Thickness x:Key="ButtonPadding">8,5,8,6</Thickness>
</Styles.Resources>
<Style Selector="Button"> <Thickness x:Key="ButtonPadding">8,5,8,6</Thickness>
<ControlTheme x:Key="{x:Type Button}" TargetType="Button">
<Setter Property="Background" Value="{DynamicResource ButtonBackground}" /> <Setter Property="Background" Value="{DynamicResource ButtonBackground}" />
<!--<Setter Property="BackgroundSizing" Value="OuterBorderEdge" />-->
<Setter Property="Foreground" Value="{DynamicResource ButtonForeground}" /> <Setter Property="Foreground" Value="{DynamicResource ButtonForeground}" />
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource ButtonBorderThemeThickness}" /> <Setter Property="BorderThickness" Value="{DynamicResource ButtonBorderThemeThickness}" />
@ -22,8 +20,13 @@
<Setter Property="Padding" Value="{DynamicResource ButtonPadding}" /> <Setter Property="Padding" Value="{DynamicResource ButtonPadding}" />
<Setter Property="HorizontalAlignment" Value="Left" /> <Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="VerticalAlignment" Value="Center" />
<!--<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}" /> <Setter Property="RenderTransform" Value="none" />
<Setter Property="FocusVisualMargin" Value="-3" />--> <Setter Property="Transitions">
<Transitions>
<TransformOperationsTransition Property="RenderTransform" Duration="0:0:.075" />
</Transitions>
</Setter>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<ContentPresenter x:Name="PART_ContentPresenter" <ContentPresenter x:Name="PART_ContentPresenter"
@ -46,6 +49,10 @@
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundPointerOver}" /> <Setter Property="Foreground" Value="{DynamicResource ButtonForegroundPointerOver}" />
</Style> </Style>
<Style Selector="^:pressed">
<Setter Property="RenderTransform" Value="scale(0.98)" />
</Style>
<Style Selector="^:pressed /template/ ContentPresenter#PART_ContentPresenter"> <Style Selector="^:pressed /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundPressed}" /> <Setter Property="Background" Value="{DynamicResource ButtonBackgroundPressed}" />
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushPressed}" /> <Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushPressed}" />
@ -83,19 +90,5 @@
<Setter Property="Foreground" Value="{DynamicResource AccentButtonForegroundDisabled}" /> <Setter Property="Foreground" Value="{DynamicResource AccentButtonForegroundDisabled}" />
</Style> </Style>
</Style> </Style>
</Style> </ControlTheme>
</ResourceDictionary>
<Style Selector="Button, RepeatButton, ToggleButton, DropDownButton">
<Setter Property="RenderTransform" Value="none" />
<Setter Property="Transitions">
<Transitions>
<TransformOperationsTransition Property="RenderTransform" Duration="0:0:.075" />
</Transitions>
</Setter>
</Style>
<Style Selector="Button:pressed, RepeatButton:pressed, ToggleButton:pressed, DropDownButton:pressed">
<Setter Property="RenderTransform" Value="scale(0.98)" />
</Style>
</Styles>

184
src/Avalonia.Themes.Fluent/Controls/ButtonSpinner.xaml

@ -1,58 +1,57 @@
<Styles xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=netstandard" xmlns:sys="clr-namespace:System;assembly=netstandard"
xmlns:converters="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls" xmlns:converters="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls"
x:CompileBindings="True"> x:CompileBindings="True">
<Design.PreviewWith> <Design.PreviewWith>
<Border Padding="20" <Border Padding="20">
Background="Black">
<StackPanel Spacing="20"> <StackPanel Spacing="20">
<ButtonSpinner ButtonSpinnerLocation="Right" <ButtonSpinner Content="Right spinner" />
Content="Right disabled inline spinner"
AllowSpin="False">
<DataValidationErrors.Error>
<sys:Exception />
</DataValidationErrors.Error>
</ButtonSpinner>
<ButtonSpinner ButtonSpinnerLocation="Left" <ButtonSpinner ButtonSpinnerLocation="Left"
Content="Left spinner" /> Content="Left spinner" />
<ButtonSpinner BorderThickness="2"
BorderBrush="Blue"
Content="Right Border" />
<ButtonSpinner ButtonSpinnerLocation="Left"
BorderThickness="2"
BorderBrush="Blue"
Content="Left Border" />
<ButtonSpinner Content="Right disabled"
AllowSpin="False"/>
<ButtonSpinner ButtonSpinnerLocation="Left"
Content="Left disabled"
AllowSpin="False"/>
<ButtonSpinner ShowButtonSpinner="False" <ButtonSpinner ShowButtonSpinner="False"
Content="Hide spinner" /> Content="Hide spinner" />
<ButtonSpinner Content="Error">
<DataValidationErrors.Error>
<sys:Exception>
<x:Arguments>
<x:String>Error</x:String>
</x:Arguments>
</sys:Exception>
</DataValidationErrors.Error>
</ButtonSpinner>
</StackPanel> </StackPanel>
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Styles.Resources> <converters:MarginMultiplierConverter x:Key="ButtonSpinnerLeftThickness" Indent="1" Left="True" />
<converters:MarginMultiplierConverter x:Key="ButtonSpinner_OnlyLeftThinknessConverter" <converters:MarginMultiplierConverter x:Key="ButtonSpinnerRightThickness" Indent="1" Right="True" />
Indent="1" <StreamGeometry x:Key="ButtonSpinnerIncreaseButtonIcon">M0,9 L10,0 20,9 19,10 10,2 1,10 z</StreamGeometry>
Left="True" /> <StreamGeometry x:Key="ButtonSpinnerDecreaseButtonIcon">M0,1 L10,10 20,1 19,0 10,8 1,0 z</StreamGeometry>
<converters:MarginMultiplierConverter x:Key="ButtonSpinner_OnlyRightThinknessConverter"
Indent="1"
Right="True" />
<StreamGeometry x:Key="ButtonSpinnerIncreaseButtonIcon">M0,9 L10,0 20,9 19,10 10,2 1,10 z</StreamGeometry> <ControlTheme x:Key="FluentButtonSpinnerRepeatButton" TargetType="RepeatButton" BasedOn="{StaticResource {x:Type RepeatButton}}">
<StreamGeometry x:Key="ButtonSpinnerDecreaseButtonIcon">M0,1 L10,10 20,1 19,0 10,8 1,0 z</StreamGeometry> <Setter Property="CornerRadius" Value="0"/>
</Styles.Resources>
<!-- RepeatButton.ButtonSpinnerRepeatButton -->
<Style Selector="RepeatButton.ButtonSpinnerRepeatButton">
<Setter Property="MinWidth" Value="34" /> <Setter Property="MinWidth" Value="34" />
<Setter Property="VerticalAlignment" Value="Stretch" /> <Setter Property="VerticalAlignment" Value="Stretch" />
</Style> <Style Selector="^:disabled /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="BorderBrush" Value="{TemplateBinding BorderBrush}" />
<Style Selector="RepeatButton.ButtonSpinnerRepeatButton /template/ ContentPresenter"> <Setter Property="Foreground" Value="{DynamicResource RepeatButtonForegroundDisabled}"/>
<Setter Property="CornerRadius" Value="0" /> </Style>
<Setter Property="BorderBrush" Value="{TemplateBinding BorderBrush}" /> </ControlTheme>
</Style>
<Style Selector="RepeatButton.ButtonSpinnerRepeatButton:disabled">
<Setter Property="BorderBrush" Value="{TemplateBinding BorderBrush}" />
</Style>
<Style Selector="RepeatButton.ButtonSpinnerRepeatButton:disabled > Path">
<Setter Property="Fill" Value="{DynamicResource RepeatButtonForegroundDisabled}" />
</Style>
<!-- ButtonSpinner --> <ControlTheme x:Key="{x:Type ButtonSpinner}" TargetType="ButtonSpinner">
<Style Selector="ButtonSpinner">
<Setter Property="Background" Value="Transparent" /> <Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" /> <Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" />
<Setter Property="Padding" Value="10, 0" /> <Setter Property="Padding" Value="10, 0" />
@ -61,7 +60,7 @@
<Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThickness}" /> <Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThickness}" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" /> <Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="MinHeight" Value="{DynamicResource TextControlThemeMinHeight}" /> <Setter Property="MinHeight" Value="{DynamicResource TextControlThemeMinHeight}" />
<Setter Property="MinWidth" Value="{DynamicResource TextControlThemeMinWidth}" /> <Setter Property="MinWidth" Value="{DynamicResource TextControlThemeMinWidth}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> <Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="VerticalContentAlignment" Value="Center" />
@ -74,76 +73,67 @@
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}" CornerRadius="{TemplateBinding CornerRadius}"
MinHeight="{TemplateBinding MinHeight}"> MinHeight="{TemplateBinding MinHeight}">
<Grid ColumnDefinitions="Auto,*,Auto"> <DockPanel>
<ContentPresenter Name="PART_ContentPresenter"
Grid.Column="1"
ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Padding="{TemplateBinding Padding}" />
<StackPanel Name="PART_SpinnerPanel" <StackPanel Name="PART_SpinnerPanel"
DockPanel.Dock="Right"
Orientation="Horizontal" Orientation="Horizontal"
IsVisible="{TemplateBinding ShowButtonSpinner}"> IsVisible="{TemplateBinding ShowButtonSpinner}">
<RepeatButton Name="PART_IncreaseButton" <RepeatButton Name="PART_IncreaseButton"
Classes="ButtonSpinnerRepeatButton" Theme="{StaticResource FluentButtonSpinnerRepeatButton}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness, Converter={StaticResource ButtonSpinnerLeftThickness}}"
CornerRadius="0"
VerticalAlignment="Stretch"
VerticalContentAlignment="Center" VerticalContentAlignment="Center"
Foreground="{TemplateBinding Foreground}" Foreground="{TemplateBinding Foreground}"
BorderBrush="{TemplateBinding BorderBrush}" FontSize="{TemplateBinding FontSize}"
Background="{TemplateBinding Background}" MinWidth="34">
FontSize="{TemplateBinding FontSize}"> <PathIcon Width="16"
<Path Fill="{TemplateBinding Foreground}" Height="8"
Width="16" Data="{StaticResource ButtonSpinnerIncreaseButtonIcon}" />
Height="8"
Stretch="Uniform"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="{StaticResource ButtonSpinnerIncreaseButtonIcon}" />
</RepeatButton> </RepeatButton>
<RepeatButton Name="PART_DecreaseButton" <RepeatButton Name="PART_DecreaseButton"
Classes="ButtonSpinnerRepeatButton" Theme="{StaticResource FluentButtonSpinnerRepeatButton}"
Foreground="{TemplateBinding Foreground}"
BorderBrush="{TemplateBinding BorderBrush}"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness, Converter={StaticResource ButtonSpinnerLeftThickness}}"
CornerRadius="0"
VerticalAlignment="Stretch"
VerticalContentAlignment="Center" VerticalContentAlignment="Center"
FontSize="{TemplateBinding FontSize}"> Foreground="{TemplateBinding Foreground}"
<Path Fill="{TemplateBinding Foreground}" FontSize="{TemplateBinding FontSize}"
Width="16" MinWidth="34">
Height="8" <PathIcon Width="16"
Stretch="Uniform" Height="8"
HorizontalAlignment="Center" Data="{StaticResource ButtonSpinnerDecreaseButtonIcon}" />
VerticalAlignment="Center"
Data="{StaticResource ButtonSpinnerDecreaseButtonIcon}" />
</RepeatButton> </RepeatButton>
</StackPanel> </StackPanel>
</Grid>
<ContentPresenter Name="PART_ContentPresenter"
Grid.Column="1"
ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Padding="{TemplateBinding Padding}" />
</DockPanel>
</Border> </Border>
</DataValidationErrors> </DataValidationErrors>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> <Style Selector="^:left">
<Style Selector="^ /template/ StackPanel#PART_SpinnerPanel">
<!-- ButtonSpinnerLocation=Right --> <Setter Property="DockPanel.Dock" Value="Left"/>
<Style Selector="ButtonSpinner:right /template/ StackPanel#PART_SpinnerPanel"> </Style>
<Setter Property="Grid.Column" Value="2" /> <Style Selector="^ /template/ RepeatButton">
</Style> <Setter Property="BorderThickness" Value="{TemplateBinding BorderThickness, Converter={StaticResource ButtonSpinnerRightThickness}}"/>
<Style Selector="ButtonSpinner:right /template/ RepeatButton.ButtonSpinnerRepeatButton"> </Style>
<Setter Property="BorderThickness" Value="{Binding $parent[ButtonSpinner].BorderThickness, Converter={StaticResource ButtonSpinner_OnlyLeftThinknessConverter}}" /> </Style>
</Style> <Style Selector="^:error">
<Setter Property="BorderBrush" Value="{DynamicResource SystemErrorTextColor}" />
<!-- ButtonSpinnerLocation=Left --> </Style>
<Style Selector="ButtonSpinner:left /template/ StackPanel#PART_SpinnerPanel"> </ControlTheme>
<Setter Property="Grid.Column" Value="0" />
</Style>
<Style Selector="ButtonSpinner:left /template/ RepeatButton.ButtonSpinnerRepeatButton">
<Setter Property="BorderThickness" Value="{Binding $parent[ButtonSpinner].BorderThickness, Converter={StaticResource ButtonSpinner_OnlyRightThinknessConverter}}" />
</Style>
<!-- Error state -->
<Style Selector="ButtonSpinner:error">
<Setter Property="BorderBrush" Value="{DynamicResource SystemErrorTextColor}" />
</Style>
</Styles> </ResourceDictionary>

42
src/Avalonia.Themes.Fluent/Controls/Calendar.xaml

@ -1,17 +1,19 @@
<!-- <!--
// (c) Copyright Microsoft Corporation. // (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL). // This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. // Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved. // All other rights reserved.
--> -->
<Styles xmlns="https://github.com/avaloniaui"> <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith> <Design.PreviewWith>
<Border Padding="20"> <Border Padding="20">
<Calendar /> <Calendar />
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Style Selector="Calendar">
<ControlTheme x:Key="{x:Type Calendar}" TargetType="Calendar">
<Setter Property="Foreground" Value="{DynamicResource CalendarViewForeground}" /> <Setter Property="Foreground" Value="{DynamicResource CalendarViewForeground}" />
<Setter Property="Background" Value="{DynamicResource CalendarViewBackground}" /> <Setter Property="Background" Value="{DynamicResource CalendarViewBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource CalendarViewBorderBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource CalendarViewBorderBrush}" />
@ -20,19 +22,19 @@
<Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<StackPanel Name="Root" <StackPanel
HorizontalAlignment="Center" Name="Root"
ClipToBounds="True"> HorizontalAlignment="Center"
ClipToBounds="True">
<CalendarItem Name="CalendarItem" <CalendarItem
Background="{TemplateBinding Background}" Name="CalendarItem"
BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}"
HeaderBackground="{TemplateBinding HeaderBackground}" BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"/> CornerRadius="{TemplateBinding CornerRadius}"
HeaderBackground="{TemplateBinding HeaderBackground}" />
</StackPanel> </StackPanel>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> </ControlTheme>
</Styles> </ResourceDictionary>

182
src/Avalonia.Themes.Fluent/Controls/CalendarButton.xaml

@ -1,121 +1,117 @@
<!-- <!--
// (c) Copyright Microsoft Corporation. // (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL). // This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. // Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved. // All other rights reserved.
--> -->
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Spacing="20">
<CalendarButton/>
</StackPanel>
</Border>
</Design.PreviewWith>
<Styles xmlns="https://github.com/avaloniaui"> <ControlTheme x:Key="{x:Type CalendarButton}" TargetType="CalendarButton">
<Style Selector="CalendarButton"> <Setter Property="ClickMode" Value="Release" />
<Setter Property="ClickMode" Value="Release"/> <Setter Property="MinWidth" Value="40" />
<Setter Property="MinWidth" Value="40"/> <Setter Property="MinHeight" Value="40" />
<Setter Property="MinHeight" Value="40"/> <Setter Property="Margin" Value="1" />
<Setter Property="Margin" Value="1"/> <Setter Property="Padding" Value="0,0,0,0" />
<Setter Property="Padding" Value="0,0,0,0"/>
<!--These are actually set on the CalendarView in WinUI--> <!--These are actually set on the CalendarView in WinUI-->
<Setter Property="Foreground" Value="{DynamicResource CalendarViewCalendarItemForeground}"/> <Setter Property="Foreground" Value="{DynamicResource CalendarViewCalendarItemForeground}" />
<Setter Property="Background" Value="{DynamicResource CalendarViewCalendarItemRevealBackground}"/> <Setter Property="Background" Value="{DynamicResource CalendarViewCalendarItemRevealBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource CalendarViewCalendarItemRevealBorderBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource CalendarViewCalendarItemRevealBorderBrush}" />
<Setter Property="BorderThickness" Value="2"/> <Setter Property="BorderThickness" Value="2" />
<Setter Property="FontSize" Value="20"/> <Setter Property="FontSize" Value="20" />
<Setter Property="ClipToBounds" Value="False"/> <Setter Property="ClipToBounds" Value="False" />
<Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Panel> <Panel>
<!-- To mimic WinUI SystemFocusVisual, Focus visual is drawn outside the bounds of the item --> <!-- To mimic WinUI SystemFocusVisual, Focus visual is drawn outside the bounds of the item -->
<Border Name="Root" Background="{TemplateBinding Background}" <Border Name="Root" Background="{TemplateBinding Background}"
BorderThickness="0" ClipToBounds="True"> BorderThickness="0" ClipToBounds="True">
<ContentControl Name="Content" <ContentControl Name="Content"
ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}" Content="{TemplateBinding Content}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
FontSize="{TemplateBinding FontSize}" FontSize="{TemplateBinding FontSize}"
Margin="{TemplateBinding Padding}"/> Margin="{TemplateBinding Padding}" />
</Border> </Border>
<!-- Drawn Border should render on top of background to preserve the 1px <!-- Drawn Border should render on top of background to preserve the 1px margin between items -->
margin between items-->
<Border Name="Border" <Border Name="Border"
BorderThickness="2" BorderThickness="2"
BorderBrush="{TemplateBinding BorderBrush}"/> BorderBrush="{TemplateBinding BorderBrush}" />
<!--Removed for now...WinUI doesn't have selection follow focus, and only uses
focus visual w/ keyboard focus
<Border Name="FocusVisual" BorderThickness="2"
BorderBrush="{DynamicResource SystemControlHighlightBaseHighBrush}"
IsHitTestVisible="False"
Margin="-2" CornerRadius="{DynamicResource ControlCornerRadius}"/>-->
</Panel> </Panel>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style>
<!--<Style Selector="CalendarButton /template/ Border#FocusVisual">
<Setter Property="IsVisible" Value="False"/>
</Style>-->
<Style Selector="CalendarButton:pointerover /template/ Border#Border"> <Style Selector="^:pointerover /template/ Border#Border">
<Setter Property="BorderBrush" Value="{DynamicResource CalendarViewHoverBorderBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource CalendarViewHoverBorderBrush}" />
</Style> </Style>
<Style Selector="CalendarButton:pressed /template/ Border#Border">
<Setter Property="BorderBrush" Value="{DynamicResource CalendarViewPressedBorderBrush}"/>
</Style>
<!-- Adjusted :selected to look like :today from DayItem --> <Style Selector="^:pressed /template/ Border#Border">
<Style Selector="CalendarButton:selected /template/ Border#Root"> <Setter Property="BorderBrush" Value="{DynamicResource SystemAccentColorDark2}" />
<Setter Property="Background" Value="{DynamicResource SystemAccentColor}"/> </Style>
</Style>
<Style Selector="CalendarButton:selected /template/ Border#Border"> <!-- Adjusted :selected to look like :today from DayItem -->
<Setter Property="BorderBrush" Value="{DynamicResource CalendarViewSelectedBorderBrush}"/> <Style Selector="^:selected">
</Style> <Style Selector="^ /template/ Border#Root">
<Style Selector="CalendarButton:selected:pointerover /template/ Border#Root"> <Setter Property="Background" Value="{DynamicResource SystemAccentColor}" />
<Setter Property="Background"> </Style>
<SolidColorBrush Color="{DynamicResource SystemAccentColor}"/>
</Setter> <Style Selector="^ /template/ Border#Border">
</Style> <Setter Property="BorderBrush" Value="{DynamicResource CalendarViewSelectedBorderBrush}" />
<Style Selector="CalendarButton:selected:pointerover /template/ Border#Border"> </Style>
<Setter Property="BorderBrush">
<SolidColorBrush Color="{DynamicResource SystemAccentColorDark1}"/> <Style Selector="^ /template/ ContentControl#Content">
</Setter> <Setter Property="Foreground" Value="{DynamicResource CalendarViewTodayForeground}" />
</Style> <Setter Property="FontWeight" Value="SemiBold" />
<Style Selector="CalendarButton:selected:pressed /template/ Border#Root"> </Style>
<Setter Property="Background">
<SolidColorBrush Color="{DynamicResource SystemAccentColor}"/> <Style Selector="^:pointerover">
</Setter> <Style Selector="^ /template/ Border#Border">
</Style> <Setter Property="BorderBrush" Value="{DynamicResource SystemAccentColorDark1}" />
<Style Selector="CalendarButton:pressed /template/ Border#Border"> </Style>
<Setter Property="BorderBrush"> <Style Selector="^ /template/ Border#Root">
<SolidColorBrush Color="{DynamicResource SystemAccentColorDark2}"/> <Setter Property="Background" Value="{DynamicResource SystemAccentColor}" />
</Setter> </Style>
</Style> </Style>
<Style Selector="CalendarButton:selected /template/ ContentControl#Content"> <Style Selector="^:pressed">
<Setter Property="Foreground" Value="{DynamicResource CalendarViewTodayForeground}"/> <Style Selector="^ /template/ Border#Border">
<Setter Property="FontWeight" Value="SemiBold"/> <Setter Property="BorderBrush" Value="{DynamicResource SystemAccentColorDark2}" />
</Style> </Style>
<!-- WinUI calls this OutOfFocus --> <Style Selector="^ /template/ Border#Root">
<Style Selector="CalendarButton:inactive /template/ Border#Root"> <Setter Property="Background" Value="{DynamicResource SystemAccentColor}" />
<!-- These are probably set in code, but consistent --> </Style>
<Setter Property="Background" Value="{DynamicResource CalendarViewOutOfScopeBackground}"/> </Style>
</Style> </Style>
<Style Selector="CalendarButton:inactive /template/ ContentControl#Content">
<Setter Property="Foreground" Value="{DynamicResource CalendarViewOutOfScopeForeground}"/>
</Style>
<Style Selector="CalendarButton:blackout /template/ ContentControl#Content"> <!-- WinUI calls this OutOfFocus -->
<Setter Property="Foreground" Value="{DynamicResource CalendarViewBlackoutForeground}"/> <Style Selector="^:inactive">
</Style> <Style Selector="^ /template/ Border#Root">
<!-- These are probably set in code, but consistent -->
<Setter Property="Background" Value="{DynamicResource CalendarViewOutOfScopeBackground}"/>
</Style>
<Style Selector="^ /template/ ContentControl#Content">
<Setter Property="Foreground" Value="{DynamicResource CalendarViewOutOfScopeForeground}"/>
</Style>
</Style>
<!--<Style Selector="CalendarButton:dayfocused /template/ Border#FocusVisual"> <Style Selector="^:blackout /template/ ContentControl#Content">
<Setter Property="IsVisible" Value="True"/> <Setter Property="Foreground" Value="{DynamicResource CalendarViewBlackoutForeground}" />
</Style>--> </Style>
<Style Selector="CalendarDayButton:disabled /template/ ContentControl#Content"> <Style Selector="^:disabled /template/ ContentControl#Content">
<Setter Property="Foreground" Value="{DynamicResource CalendarViewWeekDayForegroundDisabled}"/> <Setter Property="Foreground" Value="{DynamicResource CalendarViewWeekDayForegroundDisabled}" />
</Style> </Style>
</Styles> </ControlTheme>
</ResourceDictionary>

236
src/Avalonia.Themes.Fluent/Controls/CalendarDatePicker.xaml

@ -1,32 +1,77 @@
<Styles xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=netstandard" xmlns:sys="clr-namespace:System;assembly=netstandard"
x:CompileBindings="True"> x:CompileBindings="True">
<Design.PreviewWith> <Design.PreviewWith>
<Border Margin="20, 20, 20, 200"> <Border Margin="20, 20, 20, 200">
<CalendarDatePicker Width="200" <CalendarDatePicker Width="200" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" />
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center" />
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Styles.Resources> <x:Double x:Key="CalendarDatePickerCurrentDayFontSize">12</x:Double>
<x:Double x:Key="CalendarDatePickerCurrentDayFontSize">12</x:Double> <x:Double x:Key="CalendarDatePickerMinHeight">32</x:Double>
<x:Double x:Key="CalendarDatePickerMinHeight">32</x:Double>
</Styles.Resources> <ControlTheme x:Key="FluentCalendarDatePickerButton" TargetType="Button">
<Setter Property="TextElement.Foreground" Value="{DynamicResource CalendarDatePickerCalendarGlyphForeground}" />
<Style Selector="CalendarDatePicker"> <Setter Property="Margin" Value="2,0,4,0" />
<Setter Property="Background" Value="{DynamicResource CalendarDatePickerBackground}"/> <Setter Property="Width" Value="20" />
<Setter Property="Foreground" Value="{DynamicResource CalendarDatePickerForeground}"/> <Setter Property="Template">
<Setter Property="BorderBrush" Value="{DynamicResource CalendarDatePickerBorderBrush}"/> <ControlTemplate>
<Setter Property="BorderThickness" Value="{DynamicResource CalendarDatePickerBorderThemeThickness}"/> <Grid Height="24"
Width="20"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="0"
ColumnDefinitions="*,*,*,*"
RowDefinitions="23*,19*,19*,19*"
ClipToBounds="False">
<Border Name="Background"
Margin="0,-1,0,0"
Grid.ColumnSpan="4"
Grid.Row="1"
Grid.RowSpan="3"
BorderThickness="0.5,0,0.5,0.5"
BorderBrush="{TemplateBinding Foreground}"
CornerRadius="0,0,2,2" />
<Border Grid.ColumnSpan="4"
Grid.RowSpan="1"
BorderBrush="{TemplateBinding Foreground}"
BorderThickness="0.5"
CornerRadius="2,2,0,0" />
<TextBlock Margin="0,-1,0,0"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Grid.Column="0"
Grid.Row="1"
Grid.ColumnSpan="4"
Grid.RowSpan="3"
Foreground="{TemplateBinding Foreground}"
FontSize="{DynamicResource CalendarDatePickerCurrentDayFontSize}"
Text="{Binding Source={x:Static sys:DateTime.Today}, Path=Day}" />
<Ellipse HorizontalAlignment="Center"
VerticalAlignment="Center"
Fill="{TemplateBinding Foreground}"
StrokeThickness="0"
Grid.ColumnSpan="4"
Width="3"
Height="3" />
</Grid>
</ControlTemplate>
</Setter>
</ControlTheme>
<ControlTheme x:Key="{x:Type CalendarDatePicker}" TargetType="CalendarDatePicker">
<Setter Property="Background" Value="{DynamicResource CalendarDatePickerBackground}" />
<Setter Property="Foreground" Value="{DynamicResource CalendarDatePickerForeground}" />
<Setter Property="BorderBrush" Value="{DynamicResource CalendarDatePickerBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource CalendarDatePickerBorderThemeThickness}" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" /> <Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="MinHeight" Value="{DynamicResource CalendarDatePickerMinHeight}" /> <Setter Property="MinHeight" Value="{DynamicResource CalendarDatePickerMinHeight}" />
<Setter Property="HorizontalAlignment" Value="Left" /> <Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Left" /> <Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Padding" Value="4"/> <Setter Property="Padding" Value="4" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<DataValidationErrors> <DataValidationErrors>
@ -53,8 +98,28 @@
VerticalAlignment="Stretch" VerticalAlignment="Stretch"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
Grid.Column="0" /> Grid.Column="0">
<TextBox.Styles>
<Style Selector="TextBox#PART_TextBox:focus /template/ Border#PART_BorderElement">
<!-- By default the TextBox has its own focused state, override this to disable it here -->
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0" />
</Style>
<Style Selector="TextBox#PART_TextBox:disabled">
<Style Selector="^ /template/ Border#PART_BorderElement">
<!-- By default the TextBox has its own disabled state, override this to make the border background show through -->
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
</Style>
<Style Selector="^ /template/ TextBlock#PART_Watermark, ^ TextBlock#PART_FloatingWatermark">
<Setter Property="TextElement.Foreground" Value="{DynamicResource CalendarDatePickerTextForegroundDisabled}" />
</Style>
</Style>
</TextBox.Styles>
</TextBox>
<Button Name="PART_Button" <Button Name="PART_Button"
Theme="{StaticResource FluentCalendarDatePickerButton}"
Grid.Column="1" Grid.Column="1"
Focusable="False" /> Focusable="False" />
<Popup Name="PART_Popup" <Popup Name="PART_Popup"
@ -73,110 +138,41 @@
</DataValidationErrors> </DataValidationErrors>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style>
<!-- Normal State -->
<Style Selector="CalendarDatePicker /template/ Button#PART_Button">
<Setter Property="TextElement.Foreground" Value="{DynamicResource CalendarDatePickerCalendarGlyphForeground}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Margin" Value="2,0,4,0" />
<Setter Property="Padding" Value="0" />
<Setter Property="Width" Value="20" />
<Setter Property="Template">
<ControlTemplate>
<Grid Height="24"
Width="20"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="0"
ColumnDefinitions="*,*,*,*"
RowDefinitions="23*,19*,19*,19*"
ClipToBounds="False">
<Border Name="Background"
Margin="0,-1,0,0"
Grid.ColumnSpan="4"
Grid.Row="1"
Grid.RowSpan="3"
BorderThickness="0.5,0,0.5,0.5"
BorderBrush="{TemplateBinding Foreground}"
CornerRadius="0,0,2,2" />
<Border Grid.ColumnSpan="4"
Grid.RowSpan="1"
BorderBrush="{TemplateBinding Foreground}"
BorderThickness="0.5"
CornerRadius="2,2,0,0" />
<TextBlock Margin="0,-1,0,0"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Grid.Column="0"
Grid.Row="1"
Grid.ColumnSpan="4"
Grid.RowSpan="3"
Foreground="{TemplateBinding Foreground}"
FontSize="{DynamicResource CalendarDatePickerCurrentDayFontSize}"
Text="{Binding Source={x:Static sys:DateTime.Today}, Path=Day}" />
<Ellipse HorizontalAlignment="Center"
VerticalAlignment="Center"
Fill="{TemplateBinding Foreground}"
StrokeThickness="0"
Grid.ColumnSpan="4"
Width="3"
Height="3" />
</Grid>
</ControlTemplate>
</Setter>
</Style>
<!-- Pressed State -->
<Style Selector="CalendarDatePicker:pressed /template/ Border#Background">
<Setter Property="Background" Value="{DynamicResource CalendarDatePickerBackgroundPressed}" />
<Setter Property="BorderBrush" Value="{DynamicResource CalendarDatePickerBorderBrushPressed}" />
</Style>
<!-- Pointer-over State -->
<Style Selector="CalendarDatePicker:pointerover /template/ Border#Background">
<Setter Property="Background" Value="{DynamicResource CalendarDatePickerBackgroundPointerOver}" />
<Setter Property="BorderBrush" Value="{DynamicResource CalendarDatePickerBorderBrushPointerOver}" />
</Style>
<!-- Disabled State -->
<Style Selector="CalendarDatePicker:disabled /template/ Border#Background">
<Setter Property="Background" Value="{DynamicResource CalendarDatePickerBackgroundDisabled}" />
<Setter Property="BorderBrush" Value="{DynamicResource CalendarDatePickerBorderBrushDisabled}" />
</Style>
<Style Selector="CalendarDatePicker:disabled /template/ Button#PART_Button"> <!-- Pressed State -->
<Setter Property="TextElement.Foreground" Value="{DynamicResource CalendarDatePickerCalendarGlyphForegroundDisabled}" /> <Style Selector="^:pressed /template/ Border#Background">
</Style> <Setter Property="Background" Value="{DynamicResource CalendarDatePickerBackgroundPressed}" />
<Setter Property="BorderBrush" Value="{DynamicResource CalendarDatePickerBorderBrushPressed}" />
</Style>
<Style Selector="CalendarDatePicker:disabled /template/ TextBox#PART_TextBox:disabled /template/ Border#PART_BorderElement"> <!-- Pointer-over State -->
<!-- By default the TextBox has its own disabled state, override this to make the border background show through --> <Style Selector="^:pointerover /template/ Border#Background">
<Setter Property="Background" Value="Transparent" /> <Setter Property="Background" Value="{DynamicResource CalendarDatePickerBackgroundPointerOver}" />
<Setter Property="BorderBrush" Value="Transparent" /> <Setter Property="BorderBrush" Value="{DynamicResource CalendarDatePickerBorderBrushPointerOver}" />
</Style> </Style>
<Style Selector="CalendarDatePicker:disabled /template/ TextBox#PART_TextBox:disabled /template/ TextBlock#PART_Watermark, <!-- Disabled State -->
CalendarDatePicker:disabled /template/ TextBox#PART_TextBox:disabled /template/ TextBlock#PART_FloatingWatermark"> <Style Selector="^:disabled">
<Setter Property="TextElement.Foreground" Value="{DynamicResource CalendarDatePickerTextForegroundDisabled}" /> <Style Selector="^ /template/ Border#Background">
</Style> <Setter Property="Background" Value="{DynamicResource CalendarDatePickerBackgroundDisabled}" />
<Setter Property="BorderBrush" Value="{DynamicResource CalendarDatePickerBorderBrushDisabled}" />
</Style>
<!-- Focused State --> <Style Selector="^ /template/ Button#PART_Button">
<Style Selector="CalendarDatePicker:focus-within:not(CalendarDatePicker:focus) /template/ Border#Background"> <Setter Property="TextElement.Foreground" Value="{DynamicResource CalendarDatePickerCalendarGlyphForegroundDisabled}" />
<Setter Property="Background" Value="{DynamicResource TextControlBackgroundFocused}"/> </Style>
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushFocused}"/> </Style>
<Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThicknessFocused}" />
</Style>
<Style Selector="CalendarDatePicker /template/ TextBox#PART_TextBox:focus /template/ Border#PART_BorderElement"> <!-- Focused State -->
<!-- By default the TextBox has its own focused state, override this to disable it here --> <Style Selector="^:focus-within:not(CalendarDatePicker:focus) /template/ Border#Background">
<Setter Property="Background" Value="Transparent"/> <Setter Property="Background" Value="{DynamicResource TextControlBackgroundFocused}" />
<Setter Property="BorderBrush" Value="Transparent"/> <Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushFocused}" />
<Setter Property="BorderThickness" Value="0" /> <Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThicknessFocused}" />
</Style> </Style>
<!-- Error State --> <!-- Error State -->
<Style Selector="CalendarDatePicker:error /template/ Border#Background"> <Style Selector="^:error /template/ Border#Background">
<Setter Property="BorderBrush" Value="{DynamicResource SystemControlErrorTextForegroundBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource SystemControlErrorTextForegroundBrush}" />
</Style> </Style>
</Styles> </ControlTheme>
</ResourceDictionary>

172
src/Avalonia.Themes.Fluent/Controls/CalendarDayButton.xaml

@ -1,26 +1,34 @@
<!-- <!--
// (c) Copyright Microsoft Corporation. // (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL). // This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. // Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved. // All other rights reserved.
--> -->
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Spacing="20">
<CalendarButton/>
</StackPanel>
</Border>
</Design.PreviewWith>
<Styles xmlns="https://github.com/avaloniaui"> <ControlTheme x:Key="{x:Type CalendarDayButton}" TargetType="CalendarDayButton">
<Style Selector="CalendarDayButton"> <Setter Property="ClickMode" Value="Release" />
<Setter Property="ClickMode" Value="Release"/> <Setter Property="MinWidth" Value="40" />
<Setter Property="MinWidth" Value="40"/> <Setter Property="MinHeight" Value="40" />
<Setter Property="MinHeight" Value="40"/> <Setter Property="Margin" Value="1" />
<Setter Property="Margin" Value="1"/> <Setter Property="Padding" Value="0,0,0,0" />
<Setter Property="Padding" Value="0,0,0,0"/>
<!--These are actually set on the CalendarView in WinUI--> <!--These are actually set on the CalendarView in WinUI-->
<Setter Property="Foreground" Value="{DynamicResource CalendarViewCalendarItemForeground}"/> <Setter Property="Foreground" Value="{DynamicResource CalendarViewCalendarItemForeground}" />
<Setter Property="Background" Value="{DynamicResource CalendarViewCalendarItemRevealBackground}"/> <Setter Property="Background" Value="{DynamicResource CalendarViewCalendarItemRevealBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource CalendarViewCalendarItemRevealBorderBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource CalendarViewCalendarItemRevealBorderBrush}" />
<Setter Property="BorderThickness" Value="2"/> <Setter Property="BorderThickness" Value="2" />
<Setter Property="FontSize" Value="20"/> <Setter Property="FontSize" Value="20" />
<Setter Property="ClipToBounds" Value="False"/> <Setter Property="ClipToBounds" Value="False" />
<Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Panel> <Panel>
@ -29,88 +37,76 @@
BorderThickness="0" ClipToBounds="True"> BorderThickness="0" ClipToBounds="True">
<ContentControl Name="Content" <ContentControl Name="Content"
ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}" Content="{TemplateBinding Content}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
FontSize="{TemplateBinding FontSize}" FontSize="{TemplateBinding FontSize}"
Margin="{TemplateBinding Padding}"/> Margin="{TemplateBinding Padding}" />
</Border> </Border>
<!-- Drawn Border should render on top of background to preserve the 1px <!-- Drawn Border should render on top of background to preserve the 1px margin between items-->
margin between items-->
<Border Name="Border" <Border Name="Border"
BorderThickness="2" BorderThickness="2"
BorderBrush="{TemplateBinding BorderBrush}"/> BorderBrush="{TemplateBinding BorderBrush}" />
<!--Removed for now...WinUI doesn't have selection follow focus, and only uses
focus visual w/ keyboard focus
<Border Name="FocusVisual" BorderThickness="2"
BorderBrush="{DynamicResource SystemControlHighlightBaseHighBrush}"
IsHitTestVisible="False"
Margin="-2" CornerRadius="2"/>-->
</Panel> </Panel>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style>
<!--<Style Selector="CalendarDayButton /template/ Border#FocusVisual">
<Setter Property="IsVisible" Value="False"/>
</Style>-->
<Style Selector="CalendarDayButton:pointerover /template/ Border#Border"> <Style Selector="^:pointerover /template/ Border#Border">
<Setter Property="BorderBrush" Value="{DynamicResource CalendarViewHoverBorderBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource CalendarViewHoverBorderBrush}" />
</Style> </Style>
<Style Selector="CalendarDayButton:pressed /template/ Border#Border">
<Setter Property="BorderBrush" Value="{DynamicResource CalendarViewPressedBorderBrush}"/>
</Style>
<Style Selector="CalendarDayButton:selected /template/ Border#Border">
<Setter Property="BorderBrush" Value="{DynamicResource CalendarViewSelectedBorderBrush}"/>
</Style>
<Style Selector="CalendarDayButton:selected:pointerover /template/ Border#Border">
<Setter Property="BorderBrush" Value="{DynamicResource CalendarViewSelectedHoverBorderBrush}"/>
</Style>
<Style Selector="CalendarDayButton:selected:pressed /template/ Border#Border">
<Setter Property="BorderBrush" Value="{DynamicResource CalendarViewSelectedPressedBorderBrush}"/>
</Style>
<Style Selector="CalendarDayButton:today /template/ Border#Root"> <Style Selector="^:pressed /template/ Border#Border">
<!-- These are probably set in code, but consistent --> <Setter Property="BorderBrush" Value="{DynamicResource CalendarViewPressedBorderBrush}" />
<Setter Property="Background"> </Style>
<SolidColorBrush Color="{DynamicResource SystemAccentColor}"/>
</Setter> <Style Selector="^:selected">
</Style> <Style Selector="^ /template/ Border#Border">
<Style Selector="CalendarDayButton:today:pointerover /template/ Border#Border"> <Setter Property="BorderBrush" Value="{DynamicResource CalendarViewSelectedBorderBrush}" />
<Setter Property="BorderBrush"> </Style>
<SolidColorBrush Color="{DynamicResource SystemAccentColorDark1}"/> <Style Selector="^:pointerover /template/ Border#Border">
</Setter> <Setter Property="BorderBrush" Value="{DynamicResource CalendarViewSelectedHoverBorderBrush}" />
</Style> </Style>
<Style Selector="CalendarDayButton:today:pressed /template/ Border#Border"> <Style Selector="^:pressed /template/ Border#Border">
<Setter Property="BorderBrush"> <Setter Property="BorderBrush" Value="{DynamicResource CalendarViewSelectedPressedBorderBrush}" />
<SolidColorBrush Color="{DynamicResource SystemAccentColorDark2}"/> </Style>
</Setter> </Style>
</Style>
<Style Selector="CalendarDayButton:today /template/ ContentControl#Content"> <Style Selector="^:today">
<Setter Property="Foreground" Value="{DynamicResource CalendarViewTodayForeground}"/> <Style Selector="^ /template/ Border#Root">
<Setter Property="FontWeight" Value="SemiBold"/> <Setter Property="Background" Value="{DynamicResource SystemAccentColor}" />
</Style> </Style>
<!-- These are probably set in code, but consistent -->
<Style Selector="^:pointerover /template/ Border#Border">
<Setter Property="BorderBrush" Value="{DynamicResource SystemAccentColorDark1}" />
</Style>
<Style Selector="^:pressed /template/ Border#Border">
<Setter Property="BorderBrush" Value="{DynamicResource SystemAccentColorDark2}" />
</Style>
<Style Selector="^ ContentControl#Content">
<Setter Property="Foreground" Value="{DynamicResource CalendarViewTodayForeground}" />
<Setter Property="FontWeight" Value="SemiBold" />
</Style>
</Style>
<!-- WinUI calls this OutOfFocus --> <!-- WinUI calls this OutOfFocus -->
<Style Selector="CalendarDayButton:inactive /template/ Border#Root"> <Style Selector="^:inactive">
<Setter Property="Background" Value="{DynamicResource CalendarViewOutOfScopeBackground}"/> <Style Selector="^ /template/ Border#Root">
</Style> <Setter Property="Background" Value="{DynamicResource CalendarViewOutOfScopeBackground}" />
<Style Selector="CalendarDayButton:inactive /template/ ContentControl#Content"> </Style>
<Setter Property="Foreground" Value="{DynamicResource CalendarViewOutOfScopeForeground}"/> <Style Selector="^ /template/ ContentControl#Content">
</Style> <Setter Property="Foreground" Value="{DynamicResource CalendarViewOutOfScopeForeground}" />
</Style>
</Style>
<Style Selector="CalendarDayButton:blackout /template/ ContentControl#Content"> <Style Selector="^:blackout /template/ ContentControl#Content">
<Setter Property="Foreground" Value="{DynamicResource CalendarViewBlackoutForeground}"/> <Setter Property="Foreground" Value="{DynamicResource CalendarViewBlackoutForeground}" />
</Style> </Style>
<!--<Style Selector="CalendarDayButton:dayfocused /template/ Border#FocusVisual"> <Style Selector="^:disabled /template/ ContentControl#Content">
<Setter Property="IsVisible" Value="True"/> <Setter Property="Foreground" Value="{DynamicResource CalendarViewWeekDayForegroundDisabled}" />
</Style>--> </Style>
<Style Selector="CalendarDayButton:disabled /template/ ContentControl#Content"> </ControlTheme>
<Setter Property="Foreground" Value="{DynamicResource CalendarViewWeekDayForegroundDisabled}"/> </ResourceDictionary>
</Style>
</Styles>

170
src/Avalonia.Themes.Fluent/Controls/CalendarItem.xaml

@ -1,98 +1,119 @@
<!-- <!--
// (c) Copyright Microsoft Corporation. // (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL). // This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. // Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved. // All other rights reserved.
--> -->
<ResourceDictionary xmlns="https://github.com/avaloniaui"
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=netstandard"
x:CompileBindings="True" x:CompileBindings="True"
x:DataType="CalendarItem"> x:DataType="CalendarItem">
<Design.PreviewWith> <Design.PreviewWith>
<Border Padding="20"> <Border Padding="20">
<Calendar /> <Calendar DisplayDate="2000-01-01">
<Calendar.BlackoutDates>
<CalendarDateRange>
<x:Arguments>
<sys:DateTime>2000-01-01</sys:DateTime>
<sys:DateTime>2000-01-05</sys:DateTime>
</x:Arguments>
</CalendarDateRange>
</Calendar.BlackoutDates>
</Calendar>
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Style Selector="CalendarItem">
<ControlTheme x:Key="FluentCalendarButton" TargetType="Button">
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="FontSize" Value="20" />
<Setter Property="Background" Value="{DynamicResource CalendarViewNavigationButtonBackground}" />
<Setter Property="Template">
<ControlTemplate>
<!-- HCA was changed here to ensure nav arrows display correctly -->
<ContentPresenter Name="Text" Background="{TemplateBinding Background}"
BorderBrush="{DynamicResource CalendarViewNavigationButtonBorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
Margin="{TemplateBinding Padding}"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover /template/ ContentPresenter#Text">
<Setter Property="BorderBrush" Value="{DynamicResource CalendarViewNavigationButtonBorderBrushPointerOver}" />
<Setter Property="Foreground" Value="{DynamicResource CalendarViewNavigationButtonForegroundPointerOver}" />
</Style>
<Style Selector="^:pressed /template/ ContentPresenter#Text">
<Setter Property="Foreground" Value="{DynamicResource CalendarViewNavigationButtonForegroundPressed}" />
</Style>
<Style Selector="^:disabled /template/ ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource CalendarViewWeekDayForegroundDisabled}" />
</Style>
</ControlTheme>
<ControlTheme x:Key="{x:Type CalendarItem}" TargetType="CalendarItem">
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" /> <Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="DayTitleTemplate"> <Setter Property="DayTitleTemplate">
<Template> <Template>
<TextBlock Text="{Binding}" <TextBlock Text="{Binding}"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
FontSize="12"/> FontSize="12" />
</Template> </Template>
</Setter> </Setter>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Border BorderThickness="{TemplateBinding BorderThickness}" <Border BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
CornerRadius="{TemplateBinding CornerRadius}"> CornerRadius="{TemplateBinding CornerRadius}">
<Border.Styles> <!-- To keep calendar from resizing when switching DisplayMode
<Style Selector="Button.CalendarHeader"> In WinUI Min-Width from TemplateSettings
<Setter Property="HorizontalAlignment" Value="Stretch" /> basically...MinWidth of DayItem = 40, 40 * 7 = 280 + margins/padding = ~294
<Setter Property="VerticalAlignment" Value="Stretch" /> Viewport height is set from # of rows displayed (2-8) in Month mode, = ~290 for 6 weeks (+ day names)
<Setter Property="VerticalContentAlignment" Value="Center" /> -->
<Setter Property="FontSize" Value="20" />
<Setter Property="Background" Value="{DynamicResource CalendarViewNavigationButtonBackground}"/>
<Setter Property="Template">
<ControlTemplate>
<!-- HCA was changed here to ensure nav arrows display correctly -->
<ContentPresenter Name="Text" Background="{TemplateBinding Background}"
BorderBrush="{DynamicResource CalendarViewNavigationButtonBorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
Margin="{TemplateBinding Padding}"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
</ControlTemplate>
</Setter>
</Style>
<Style Selector="Button.CalendarNavigation > Path">
<Setter Property="Stroke" Value="{DynamicResource CalendarViewForeground}"/>
</Style>
<Style Selector="Button.CalendarNavigation:pointerover > Path">
<Setter Property="Stroke" Value="{DynamicResource CalendarViewNavigationButtonForegroundPointerOver}"/>
</Style>
<Style Selector="Button.CalendarNavigation:pressed > Path">
<Setter Property="Stroke" Value="{DynamicResource CalendarViewNavigationButtonForegroundPressed}"/>
</Style>
<Style Selector="Button.CalendarHeader:pointerover /template/ ContentPresenter#Text">
<Setter Property="BorderBrush" Value="{DynamicResource CalendarViewNavigationButtonBorderBrushPointerOver}" />
<Setter Property="Foreground" Value="{DynamicResource CalendarViewNavigationButtonForegroundPointerOver}"/>
<!-- Prevent base button template:pointerover from overriding background here -->
<Setter Property="Background" Value="{DynamicResource CalendarViewNavigationButtonBackground}"/>
</Style>
<Style Selector="Button.CalendarHeader:pressed /template/ ContentPresenter#Text">
<Setter Property="Foreground" Value="{DynamicResource CalendarViewNavigationButtonForegroundPressed}"/>
<!-- Prevent base button template:pointerover from overriding background here -->
<Setter Property="Background" Value="{DynamicResource CalendarViewNavigationButtonBackground}"/>
</Style>
<Style Selector="Button.CalendarHeader:disabled /template/ ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource CalendarViewWeekDayForegroundDisabled}"/>
</Style>
</Border.Styles>
<!-- To keep calendar from resizing when switching DisplayMode
In WinUI Min-Width from TemplateSettings
basically...MinWidth of DayItem = 40, 40 * 7 = 280 + margins/padding = ~294
Viewport height is set from # of rows displayed (2-8) in Month mode, = ~290 for 6 weeks (+ day names)
-->
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" RowDefinitions="40,*" MinWidth="294"> <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" RowDefinitions="40,*" MinWidth="294">
<Grid ColumnDefinitions="5*,*,*"> <Grid ColumnDefinitions="5*,*,*">
<Button Name="HeaderButton" Classes="CalendarHeader" Foreground="{TemplateBinding Foreground}" Padding="12,0,0,0" HorizontalContentAlignment="Left" /> <Button Name="HeaderButton"
<Button Name="PreviousButton" Grid.Column="1" Classes="CalendarHeader CalendarNavigation" Foreground="{TemplateBinding Foreground}" Padding="1" HorizontalContentAlignment="Left"> Theme="{StaticResource FluentCalendarButton}"
Foreground="{TemplateBinding Foreground}"
Padding="12,0,0,0"
HorizontalContentAlignment="Left" />
<Button Name="PreviousButton"
Grid.Column="1"
Theme="{StaticResource FluentCalendarButton}"
Foreground="{TemplateBinding Foreground}"
Padding="1"
HorizontalContentAlignment="Left">
<!--Path mimics Segoe MDL2 Assets font glyph used in WinUI--> <!--Path mimics Segoe MDL2 Assets font glyph used in WinUI-->
<Path StrokeThickness="1.5" Data="M 0,9 L 9,0 L 18,9" HorizontalAlignment="Center" VerticalAlignment="Center"/> <Path Stroke="{DynamicResource CalendarViewForeground}"
StrokeThickness="1.5"
Data="M 0,9 L 9,0 L 18,9"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Button> </Button>
<Button Name="NextButton" Grid.Column="2" Classes="CalendarHeader CalendarNavigation" Foreground="{TemplateBinding Foreground}" Padding="1" HorizontalContentAlignment="Left"> <Button Name="NextButton"
Grid.Column="2"
Theme="{StaticResource FluentCalendarButton}"
Foreground="{TemplateBinding Foreground}"
Padding="1"
HorizontalContentAlignment="Left">
<!--Path mimics Segoe MDL2 Assets font glyph used in WinUI--> <!--Path mimics Segoe MDL2 Assets font glyph used in WinUI-->
<Path StrokeThickness="1.5" Data="M 0,0 L 9,9 L 18,0" HorizontalAlignment="Center" VerticalAlignment="Center"/> <Path Stroke="{DynamicResource CalendarViewForeground}"
StrokeThickness="1.5"
Data="M 0,0 L 9,9 L 18,0"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Button> </Button>
</Grid> </Grid>
<Border Name="BackgroundLayer" Background="{TemplateBinding BorderBrush}" Grid.Row="1" /> <!--Border below is used only for MonthView but it can't be moved inside of Grid because CalendarItem expects it to be empty and it will cause side-effects-->
<Grid Name="MonthView" Grid.Row="1" IsVisible="False" MinHeight="290" > <Border Name="BackgroundLayer" Background="{TemplateBinding BorderBrush}" Margin="0,38,0,0" IsVisible="{ReflectionBinding #MonthView.IsVisible}" Grid.Row="1" />
<Grid Name="MonthView" Grid.Row="1" IsVisible="False" MinHeight="290">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<!--This should always be the week day names??--> <!--This should always be the week day names??-->
<RowDefinition Height="38" /> <RowDefinition Height="38" />
@ -113,8 +134,11 @@
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
</Grid> </Grid>
<Grid Name="YearView" MinHeight="290" <Grid Name="YearView"
Grid.Row="1" IsVisible="False"> Background="{TemplateBinding BorderBrush}"
MinHeight="290"
Grid.Row="1"
IsVisible="False">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
@ -127,17 +151,15 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
</Grid> </Grid>
</Grid> </Grid>
</Border> </Border>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> <Style Selector="^ /template/ Button:pointerover > Path">
<Setter Property="Stroke" Value="{DynamicResource CalendarViewNavigationButtonForegroundPointerOver}" />
<!-- BackgroundLayer shouldn't show in the week day names row--> </Style>
<Style Selector="Calendar[DisplayMode=Month] CalendarItem /template/ Border#BackgroundLayer"> <Style Selector="^ /template/ Button:pressed > Path">
<Setter Property="Margin" Value="0,38,0,0"/> <Setter Property="Stroke" Value="{DynamicResource CalendarViewNavigationButtonForegroundPressed}" />
</Style> </Style>
</ControlTheme>
</Styles> </ResourceDictionary>

141
src/Avalonia.Themes.Fluent/Controls/CaptionButtons.xaml

@ -1,72 +1,97 @@
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ResourceDictionary xmlns="https://github.com/avaloniaui"
<Style Selector="CaptionButtons"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Spacing="20">
<CaptionButtons Height="30"/>
</StackPanel>
</Border>
</Design.PreviewWith>
<ControlTheme x:Key="FluentCaptionButton" TargetType="Button">
<Setter Property="Background" Value="#ffe5e5e5" />
<!-- Reusing BorderBrush to define pressed background color, as it's not used otherwise -->
<Setter Property="BorderBrush" Value="#ffcacaca" />
<Setter Property="Foreground" Value="Black"/>
<Setter Property="Width" Value="45"/>
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="Template">
<ControlTemplate>
<ContentPresenter Name="PART_ContentPresenter"
Background="Transparent"
Content="{TemplateBinding Content}"/>
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="{TemplateBinding Background}" />
</Style>
<Style Selector="^:pressed /template/ ContentPresenter">
<Setter Property="Background" Value="{TemplateBinding BorderBrush}" />
</Style>
</ControlTheme>
<ControlTheme x:Key="{x:Type CaptionButtons}" TargetType="CaptionButtons">
<Setter Property="MaxHeight" Value="30" /> <Setter Property="MaxHeight" Value="30" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<StackPanel Spacing="2" VerticalAlignment="Stretch" TextElement.FontSize="10" Orientation="Horizontal"> <StackPanel Spacing="2" VerticalAlignment="Stretch" TextElement.FontSize="10" Orientation="Horizontal">
<StackPanel.Styles> <Button x:Name="PART_FullScreenButton"
<Style Selector="Panel"> Theme="{StaticResource FluentCaptionButton}"
<Setter Property="Width" Value="45" /> IsVisible="False">
<Setter Property="Background" Value="Transparent" /> <Viewbox Width="11" Margin="2">
</Style> <Path Name="FullScreenButtonPath"
<Style Selector="Panel:pointerover"> Stretch="UniformToFill"
<Setter Property="Background" Value="#7F7f7f7f" /> Fill="{TemplateBinding Foreground}"
</Style> Data="M2048 2048v-819h-205v469l-1493 -1493h469v-205h-819v819h205v-469l1493 1493h-469v205h819z" />
<Style Selector="Panel#PART_CloseButton:pointerover">
<Setter Property="Background" Value="#7FFF0000" />
</Style>
<Style Selector="Viewbox">
<Setter Property="Width" Value="11" />
<Setter Property="Margin" Value="2" />
</Style>
</StackPanel.Styles>
<Panel x:Name="PART_FullScreenButton">
<Viewbox>
<Path Stretch="UniformToFill" Fill="{TemplateBinding Foreground}" />
</Viewbox> </Viewbox>
</Panel> </Button>
<Button x:Name="PART_MinimiseButton"
<Panel x:Name="PART_MinimiseButton"> Theme="{StaticResource FluentCaptionButton}">
<Viewbox> <Viewbox Width="11" Margin="2">
<Path Stretch="UniformToFill" Fill="{TemplateBinding Foreground}" Data="M2048 1229v-205h-2048v205h2048z" /> <Path Stretch="UniformToFill"
Fill="{TemplateBinding Foreground}"
Data="M2048 1229v-205h-2048v205h2048z" />
</Viewbox> </Viewbox>
</Panel> </Button>
<Button x:Name="PART_RestoreButton"
<Panel x:Name="PART_RestoreButton"> Theme="{StaticResource FluentCaptionButton}">
<Viewbox> <Viewbox Width="11" Margin="2">
<Viewbox.RenderTransform> <Viewbox.RenderTransform>
<RotateTransform Angle="-90" /> <RotateTransform Angle="-90" />
</Viewbox.RenderTransform> </Viewbox.RenderTransform>
<Path Stretch="UniformToFill" Fill="{TemplateBinding Foreground}"/> <Path Name="RestoreButtonPath"
Stretch="UniformToFill"
Fill="{TemplateBinding Foreground}"
Data="M2048 2048v-2048h-2048v2048h2048zM1843 1843h-1638v-1638h1638v1638z"/>
</Viewbox> </Viewbox>
</Panel> </Button>
<Button x:Name="PART_CloseButton"
<Panel x:Name="PART_CloseButton"> Background="#ffe81123"
<Viewbox> BorderBrush="#fff1707a"
<Path Stretch="UniformToFill" Fill="{TemplateBinding Foreground}" Data="M1169 1024l879 -879l-145 -145l-879 879l-879 -879l-145 145l879 879l-879 879l145 145l879 -879l879 879l145 -145z" /> Theme="{StaticResource FluentCaptionButton}">
<Viewbox Width="11" Margin="2">
<Path Stretch="UniformToFill"
Fill="{TemplateBinding Foreground}"
Data="M1169 1024l879 -879l-145 -145l-879 879l-879 -879l-145 145l879 879l-879 879l145 145l879 -879l879 879l145 -145z" />
</Viewbox> </Viewbox>
</Panel> </Button>
</StackPanel> </StackPanel>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> <Style Selector="^:maximized /template/ Path#RestoreButtonPath">
<Style Selector="CaptionButtons Panel#PART_RestoreButton Path"> <Setter Property="Data" Value="M2048 410h-410v-410h-1638v1638h410v410h1638v-1638zM1434 1434h-1229v-1229h1229v1229zM1843 1843h-1229v-205h1024v-1024h205v1229z" />
<Setter Property="Data" Value="M2048 2048v-2048h-2048v2048h2048zM1843 1843h-1638v-1638h1638v1638z" /> </Style>
</Style> <Style Selector="^:fullscreen /template/ Path#PART_FullScreenButtonPath">
<Style Selector="CaptionButtons:maximized Panel#PART_RestoreButton Path"> <Setter Property="IsVisible" Value="True" />
<Setter Property="Data" Value="M2048 410h-410v-410h-1638v1638h410v410h1638v-1638zM1434 1434h-1229v-1229h1229v1229zM1843 1843h-1229v-205h1024v-1024h205v1229z" /> <Setter Property="Data" Value="M205 1024h819v-819h-205v469l-674 -674l-145 145l674 674h-469v205zM1374 1229h469v-205h-819v819h205v-469l674 674l145 -145z" />
</Style> </Style>
<Style Selector="CaptionButtons Panel#PART_FullScreenButton"> <Style Selector="^:fullscreen /template/ Panel#PART_RestoreButton">
<Setter Property="IsVisible" Value="False" /> <Setter Property="IsVisible" Value="False" />
</Style> </Style>
<Style Selector="CaptionButtons Panel#PART_FullScreenButton Path"> <Style Selector="^:fullscreen /template/ Panel#PART_MinimiseButton">
<Setter Property="Data" Value="M2048 2048v-819h-205v469l-1493 -1493h469v-205h-819v819h205v-469l1493 1493h-469v205h819z" /> <Setter Property="IsVisible" Value="False" />
</Style> </Style>
<Style Selector="CaptionButtons:fullscreen Panel#PART_FullScreenButton Path"> </ControlTheme>
<Setter Property="IsVisible" Value="True" /> </ResourceDictionary>
<Setter Property="Data" Value="M205 1024h819v-819h-205v469l-674 -674l-145 145l674 674h-469v205zM1374 1229h469v-205h-819v819h205v-469l674 674l145 -145z" />
</Style>
<Style Selector="CaptionButtons:fullscreen Panel#PART_RestoreButton, CaptionButtons:fullscreen Panel#PART_MinimiseButton">
<Setter Property="IsVisible" Value="False" />
</Style>
</Styles>

37
src/Avalonia.Themes.Fluent/Controls/Carousel.xaml

@ -1,17 +1,20 @@
<Style xmlns="https://github.com/avaloniaui" Selector="Carousel"> <ResourceDictionary xmlns="https://github.com/avaloniaui"
<Setter Property="Template"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTemplate> <ControlTheme x:Key="{x:Type Carousel}" TargetType="Carousel">
<Border Background="{TemplateBinding Background}" <Setter Property="Template">
BorderBrush="{TemplateBinding BorderBrush}" <ControlTemplate>
BorderThickness="{TemplateBinding BorderThickness}" <Border Background="{TemplateBinding Background}"
CornerRadius="{TemplateBinding CornerRadius}"> BorderBrush="{TemplateBinding BorderBrush}"
<CarouselPresenter IsVirtualized="{TemplateBinding IsVirtualized}" BorderThickness="{TemplateBinding BorderThickness}"
Items="{TemplateBinding Items}" CornerRadius="{TemplateBinding CornerRadius}">
ItemsPanel="{TemplateBinding ItemsPanel}" <CarouselPresenter IsVirtualized="{TemplateBinding IsVirtualized}"
Margin="{TemplateBinding Padding}" Items="{TemplateBinding Items}"
SelectedIndex="{TemplateBinding SelectedIndex}" ItemsPanel="{TemplateBinding ItemsPanel}"
PageTransition="{TemplateBinding PageTransition}"/> Margin="{TemplateBinding Padding}"
</Border> SelectedIndex="{TemplateBinding SelectedIndex}"
</ControlTemplate> PageTransition="{TemplateBinding PageTransition}"/>
</Setter> </Border>
</Style> </ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>

451
src/Avalonia.Themes.Fluent/Controls/CheckBox.xaml

@ -1,297 +1,298 @@
<Style xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
Selector="CheckBox">
<Design.PreviewWith> <Design.PreviewWith>
<Border Padding="20"> <Border Padding="20">
<CheckBox IsThreeState="True" IsChecked="True" Content="Content" Foreground="Gold" /> <StackPanel Spacing="20">
<CheckBox>Unchecked</CheckBox>
<CheckBox IsChecked="True">Checked</CheckBox>
<CheckBox IsThreeState="True" IsChecked="{x:Null}">Indeterminate</CheckBox>
<CheckBox Width="120">Checkbox should wrap its text</CheckBox>
</StackPanel>
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Setter Property="Padding" Value="8,0,0,0" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="MinHeight" Value="32" />
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundUnchecked}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundUnchecked}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushUnchecked}" />
<Setter Property="Template">
<ControlTemplate>
<Grid x:Name="RootGrid" ColumnDefinitions="20,*">
<Border x:Name="PART_Border"
Grid.ColumnSpan="2"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}" />
<Grid VerticalAlignment="Top" Height="32">
<Border x:Name="NormalRectangle"
BorderThickness="{DynamicResource CheckBoxBorderThemeThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
UseLayoutRounding="False"
Height="20"
Width="20" />
<Viewbox UseLayoutRounding="False">
<Panel>
<Panel Height="16" Width="16" />
<Path x:Name="CheckGlyph" Stretch="Uniform" VerticalAlignment="Center" />
</Panel>
</Viewbox>
</Grid>
<ContentPresenter x:Name="ContentPresenter"
ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Grid.Column="1" />
<!-- TODO: TextWrapping="Wrap" on contentpresenter -->
</Grid>
</ControlTemplate>
</Setter>
<!-- Unchecked Normal State -->
<Style Selector="^ /template/ Border#NormalRectangle">
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeUnchecked}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillUnchecked}" />
</Style>
<Style Selector="^ /template/ Path#CheckGlyph">
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundUnchecked}" />
<Setter Property="Opacity" Value="0" />
</Style>
<!-- Unchecked PointerOver State -->
<Style Selector="^:pointerover">
<Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundUncheckedPointerOver}" />
</Style>
<Style Selector="^ /template/ Border#PART_Border">
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundUncheckedPointerOver}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushUncheckedPointerOver}" />
</Style>
<Style Selector="^ /template/ Border#NormalRectangle">
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeUncheckedPointerOver}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillUncheckedPointerOver}" />
</Style>
<Style Selector="^ /template/ Path#CheckGlyph">
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundUncheckedPointerOver}" />
</Style>
</Style>
<!-- Unchecked Pressed State -->
<Style Selector="^:pressed">
<Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundUncheckedPressed}" />
</Style>
<Style Selector="^ /template/ Border#PART_Border">
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundUncheckedPressed}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushUncheckedPressed}" />
</Style>
<Style Selector="^ /template/ Border#NormalRectangle">
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeUncheckedPressed}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillUncheckedPressed}" />
</Style>
<Style Selector="^ /template/ Path#CheckGlyph">
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundUncheckedPressed}" />
</Style>
</Style>
<!-- Unchecked Disabled state -->
<Style Selector="^:disabled">
<Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundUncheckedDisabled}" />
</Style>
<Style Selector="^ /template/ Border#PART_Border">
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundUncheckedDisabled}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushUncheckedDisabled}" />
</Style>
<Style Selector="^ /template/ Border#NormalRectangle">
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeUncheckedDisabled}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillUncheckedDisabled}" />
</Style>
<Style Selector="^ /template/ Path#CheckGlyph">
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundUncheckedDisabled}" />
</Style>
</Style>
<Style Selector="^:checked">
<!-- Checked Normal State -->
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundChecked}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundChecked}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushChecked}" />
<Style Selector="^ /template/ Border#NormalRectangle">
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundFillChecked}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillChecked}" />
</Style>
<Style Selector="^ /template/ Path#CheckGlyph"> <ControlTheme x:Key="{x:Type CheckBox}" TargetType="CheckBox">
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundChecked}" /> <Setter Property="Padding" Value="8,0,0,0" />
<Setter Property="Data" Value="M1507 31L438 1101L-119 543L-29 453L438 919L1417 -59L1507 31Z" /> <Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="Width" Value="9" /> <Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Opacity" Value="1" /> <Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="FlowDirection" Value="LeftToRight" /> <Setter Property="VerticalContentAlignment" Value="Center" />
</Style> <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="MinHeight" Value="32" />
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundUnchecked}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundUnchecked}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushUnchecked}" />
<Setter Property="Template">
<ControlTemplate>
<Grid x:Name="RootGrid" ColumnDefinitions="20,*">
<Border x:Name="PART_Border"
Grid.ColumnSpan="2"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}" />
<Grid VerticalAlignment="Top" Height="32">
<Border x:Name="NormalRectangle"
BorderBrush="{DynamicResource CheckBoxCheckBackgroundStrokeUnchecked}"
Background="{DynamicResource CheckBoxCheckBackgroundFillUnchecked}"
BorderThickness="{DynamicResource CheckBoxBorderThemeThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
UseLayoutRounding="False"
Height="20"
Width="20" />
<Viewbox UseLayoutRounding="False">
<Panel>
<Panel Height="16" Width="16" />
<Path x:Name="CheckGlyph"
Opacity="0"
Fill="{DynamicResource CheckBoxCheckGlyphForegroundUnchecked}"
Stretch="Uniform"
VerticalAlignment="Center" />
</Panel>
</Viewbox>
</Grid>
<ContentPresenter x:Name="ContentPresenter"
ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
TextWrapping="Wrap"
Grid.Column="1" />
</Grid>
</ControlTemplate>
</Setter>
<!-- Checked PointerOver State --> <!-- Unchecked PointerOver State -->
<Style Selector="^:pointerover"> <Style Selector="^:pointerover">
<Style Selector="^ /template/ ContentPresenter#ContentPresenter"> <Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundCheckedPointerOver}" /> <Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundUncheckedPointerOver}" />
</Style> </Style>
<Style Selector="^ /template/ Border#PART_Border"> <Style Selector="^ /template/ Border#PART_Border">
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundCheckedPointerOver}" /> <Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundUncheckedPointerOver}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushCheckedPointerOver}" /> <Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushUncheckedPointerOver}" />
</Style> </Style>
<Style Selector="^ /template/ Border#NormalRectangle"> <Style Selector="^ /template/ Border#NormalRectangle">
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeCheckedPointerOver}" /> <Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeUncheckedPointerOver}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillCheckedPointerOver}" /> <Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillUncheckedPointerOver}" />
</Style> </Style>
<Style Selector="^ /template/ Path#CheckGlyph"> <Style Selector="^ /template/ Path#CheckGlyph">
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundCheckedPointerOver}" /> <Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundUncheckedPointerOver}" />
</Style> </Style>
</Style> </Style>
<!-- Checked Pressed State --> <!-- Unchecked Pressed State -->
<Style Selector="^:pressed"> <Style Selector="^:pressed">
<Style Selector="^ /template/ ContentPresenter#ContentPresenter"> <Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundCheckedPressed}" /> <Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundUncheckedPressed}" />
</Style> </Style>
<Style Selector="^ /template/ Border#PART_Border"> <Style Selector="^ /template/ Border#PART_Border">
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundCheckedPressed}" /> <Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundUncheckedPressed}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushCheckedPressed}" /> <Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushUncheckedPressed}" />
</Style> </Style>
<Style Selector="^ /template/ Border#NormalRectangle"> <Style Selector="^ /template/ Border#NormalRectangle">
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeCheckedPressed}" /> <Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeUncheckedPressed}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillCheckedPressed}" /> <Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillUncheckedPressed}" />
</Style> </Style>
<Style Selector="^ /template/ Path#CheckGlyph"> <Style Selector="^ /template/ Path#CheckGlyph">
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundCheckedPressed}" /> <Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundUncheckedPressed}" />
</Style> </Style>
</Style> </Style>
<!-- Checked Disabled State --> <!-- Unchecked Disabled state -->
<Style Selector="^:disabled"> <Style Selector="^:disabled">
<Style Selector="^ /template/ ContentPresenter#ContentPresenter"> <Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundCheckedDisabled}" /> <Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundUncheckedDisabled}" />
</Style> </Style>
<Style Selector="^ /template/ Border#PART_Border"> <Style Selector="^ /template/ Border#PART_Border">
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundCheckedDisabled}" /> <Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundUncheckedDisabled}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushCheckedDisabled}" /> <Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushUncheckedDisabled}" />
</Style> </Style>
<Style Selector="^ /template/ Border#NormalRectangle"> <Style Selector="^ /template/ Border#NormalRectangle">
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeCheckedDisabled}" /> <Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeUncheckedDisabled}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillCheckedDisabled}" /> <Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillUncheckedDisabled}" />
</Style> </Style>
<Style Selector="^ /template/ Path#CheckGlyph"> <Style Selector="^ /template/ Path#CheckGlyph">
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundCheckedDisabled}" /> <Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundUncheckedDisabled}" />
</Style> </Style>
</Style> </Style>
</Style>
<Style Selector="^:indeterminate"> <Style Selector="^:checked">
<!-- Indeterminate Normal State --> <!-- Checked Normal State -->
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundIndeterminate}" /> <Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundChecked}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundIndeterminate}" /> <Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundChecked}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushIndeterminate}" /> <Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushChecked}" />
<Style Selector="^ /template/ Border#NormalRectangle">
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeIndeterminate}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillIndeterminate}" />
</Style>
<Style Selector="^ /template/ Path#CheckGlyph"> <Style Selector="^ /template/ Border#NormalRectangle">
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundIndeterminate}" /> <Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundFillChecked}" />
<Setter Property="Data" Value="M1536 1536v-1024h-1024v1024h1024z" /> <Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillChecked}" />
<Setter Property="Width" Value="7" />
<Setter Property="Opacity" Value="1" />
</Style>
<!-- Indeterminate PointerOver State -->
<Style Selector="^:pointerover">
<Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundIndeterminatePointerOver}" />
</Style> </Style>
<Style Selector="^ /template/ Border#PART_Border"> <Style Selector="^ /template/ Path#CheckGlyph">
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundIndeterminatePointerOver}" /> <Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundChecked}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushIndeterminatePointerOver}" /> <Setter Property="Data" Value="M1507 31L438 1101L-119 543L-29 453L438 919L1417 -59L1507 31Z" />
<Setter Property="Width" Value="9" />
<Setter Property="Opacity" Value="1" />
<Setter Property="FlowDirection" Value="LeftToRight" />
</Style> </Style>
<Style Selector="^ /template/ Border#NormalRectangle"> <!-- Checked PointerOver State -->
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeIndeterminatePointerOver}" /> <Style Selector="^:pointerover">
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillIndeterminatePointerOver}" /> <Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundCheckedPointerOver}" />
</Style>
<Style Selector="^ /template/ Border#PART_Border">
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundCheckedPointerOver}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushCheckedPointerOver}" />
</Style>
<Style Selector="^ /template/ Border#NormalRectangle">
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeCheckedPointerOver}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillCheckedPointerOver}" />
</Style>
<Style Selector="^ /template/ Path#CheckGlyph">
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundCheckedPointerOver}" />
</Style>
</Style> </Style>
<Style Selector="^ /template/ Path#CheckGlyph"> <!-- Checked Pressed State -->
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundIndeterminatePointerOver}" /> <Style Selector="^:pressed">
<Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundCheckedPressed}" />
</Style>
<Style Selector="^ /template/ Border#PART_Border">
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundCheckedPressed}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushCheckedPressed}" />
</Style>
<Style Selector="^ /template/ Border#NormalRectangle">
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeCheckedPressed}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillCheckedPressed}" />
</Style>
<Style Selector="^ /template/ Path#CheckGlyph">
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundCheckedPressed}" />
</Style>
</Style> </Style>
</Style>
<!-- Indeterminate Pressed State --> <!-- Checked Disabled State -->
<Style Selector="^:pressed"> <Style Selector="^:disabled">
<Style Selector="^ /template/ ContentPresenter#ContentPresenter"> <Style Selector="^ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundIndeterminatePressed}" /> <Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundCheckedDisabled}" />
</Style>
<Style Selector="^ /template/ Border#PART_Border">
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundCheckedDisabled}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushCheckedDisabled}" />
</Style>
<Style Selector="^ /template/ Border#NormalRectangle">
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeCheckedDisabled}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillCheckedDisabled}" />
</Style>
<Style Selector="^ /template/ Path#CheckGlyph">
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundCheckedDisabled}" />
</Style>
</Style> </Style>
</Style>
<Style Selector="^ /template/ Border#PART_Border"> <Style Selector="^:indeterminate">
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundIndeterminatePressed}" /> <!-- Indeterminate Normal State -->
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushIndeterminatePressed}" /> <Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundIndeterminate}" />
</Style> <Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundIndeterminate}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushIndeterminate}" />
<Style Selector="^ /template/ Border#NormalRectangle"> <Style Selector="^ /template/ Border#NormalRectangle">
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeIndeterminatePressed}" /> <Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeIndeterminate}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillIndeterminatePressed}" /> <Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillIndeterminate}" />
</Style> </Style>
<Style Selector="^ /template/ Path#CheckGlyph"> <Style Selector="^ /template/ Path#CheckGlyph">
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundIndeterminatePressed}" /> <Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundIndeterminate}" />
<Setter Property="Data" Value="M1536 1536v-1024h-1024v1024h1024z" />
<Setter Property="Width" Value="7" />
<Setter Property="Opacity" Value="1" />
</Style> </Style>
</Style>
<!-- Indeterminate Disabled State --> <!-- Indeterminate PointerOver State -->
<Style Selector="^:disabled"> <Style Selector="^:pointerover">
<Style Selector="^ /template/ ContentPresenter#ContentPresenter"> <Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundIndeterminateDisabled}" /> <Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundIndeterminatePointerOver}" />
</Style> </Style>
<Style Selector="^ /template/ Border#PART_Border"> <Style Selector="^ /template/ Border#PART_Border">
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundIndeterminateDisabled}" /> <Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundIndeterminatePointerOver}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushIndeterminateDisabled}" /> <Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushIndeterminatePointerOver}" />
</Style>
<Style Selector="^ /template/ Border#NormalRectangle">
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeIndeterminatePointerOver}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillIndeterminatePointerOver}" />
</Style>
<Style Selector="^ /template/ Path#CheckGlyph">
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundIndeterminatePointerOver}" />
</Style>
</Style> </Style>
<Style Selector="^ /template/ Border#NormalRectangle"> <!-- Indeterminate Pressed State -->
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeIndeterminateDisabled}" /> <Style Selector="^:pressed">
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillIndeterminateDisabled}" /> <Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundIndeterminatePressed}" />
</Style>
<Style Selector="^ /template/ Border#PART_Border">
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundIndeterminatePressed}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushIndeterminatePressed}" />
</Style>
<Style Selector="^ /template/ Border#NormalRectangle">
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeIndeterminatePressed}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillIndeterminatePressed}" />
</Style>
<Style Selector="^ /template/ Path#CheckGlyph">
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundIndeterminatePressed}" />
</Style>
</Style> </Style>
<Style Selector="^ /template/ Path#CheckGlyph"> <!-- Indeterminate Disabled State -->
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundIndeterminateDisabled}" /> <Style Selector="^:disabled">
<Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundIndeterminateDisabled}" />
</Style>
<Style Selector="^ /template/ Border#PART_Border">
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundIndeterminateDisabled}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushIndeterminateDisabled}" />
</Style>
<Style Selector="^ /template/ Border#NormalRectangle">
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeIndeterminateDisabled}" />
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillIndeterminateDisabled}" />
</Style>
<Style Selector="^ /template/ Path#CheckGlyph">
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundIndeterminateDisabled}" />
</Style>
</Style> </Style>
</Style> </Style>
</Style> </ControlTheme>
</Style> </ResourceDictionary>

200
src/Avalonia.Themes.Fluent/Controls/ComboBox.xaml

@ -1,5 +1,6 @@
<Styles xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=netstandard">
<Design.PreviewWith> <Design.PreviewWith>
<Border Padding="20"> <Border Padding="20">
<StackPanel Spacing="10"> <StackPanel Spacing="10">
@ -14,19 +15,28 @@
<ComboBoxItem>Item 1</ComboBoxItem> <ComboBoxItem>Item 1</ComboBoxItem>
<ComboBoxItem>Item 2</ComboBoxItem> <ComboBoxItem>Item 2</ComboBoxItem>
</ComboBox> </ComboBox>
<ComboBox PlaceholderText="Error">
<DataValidationErrors.Error>
<sys:Exception>
<x:Arguments>
<x:String>Error</x:String>
</x:Arguments>
</sys:Exception>
</DataValidationErrors.Error>
</ComboBox>
</StackPanel> </StackPanel>
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Styles.Resources>
<Thickness x:Key="ComboBoxTopHeaderMargin">0,0,0,4</Thickness>
<x:Int32 x:Key="ComboBoxPopupMaxNumberOfItems">15</x:Int32>
<x:Int32 x:Key="ComboBoxPopupMaxNumberOfItemsThatCanBeShownOnOneSide">7</x:Int32>
<Thickness x:Key="ComboBoxPadding">12,5,0,7</Thickness> <Thickness x:Key="ComboBoxTopHeaderMargin">0,0,0,4</Thickness>
<Thickness x:Key="ComboBoxEditableTextPadding">11,5,32,6</Thickness> <x:Int32 x:Key="ComboBoxPopupMaxNumberOfItems">15</x:Int32>
<x:Double x:Key="ComboBoxMinHeight">32</x:Double> <x:Int32 x:Key="ComboBoxPopupMaxNumberOfItemsThatCanBeShownOnOneSide">7</x:Int32>
</Styles.Resources>
<Style Selector="ComboBox"> <Thickness x:Key="ComboBoxPadding">12,5,0,7</Thickness>
<Thickness x:Key="ComboBoxEditableTextPadding">11,5,32,6</Thickness>
<x:Double x:Key="ComboBoxMinHeight">32</x:Double>
<ControlTheme x:Key="{x:Type ComboBox}" TargetType="ComboBox">
<Setter Property="Padding" Value="{DynamicResource ComboBoxPadding}" /> <Setter Property="Padding" Value="{DynamicResource ComboBoxPadding}" />
<Setter Property="FocusAdorner" Value="{x:Null}" /> <Setter Property="FocusAdorner" Value="{x:Null}" />
<Setter Property="MaxDropDownHeight" Value="504" /> <Setter Property="MaxDropDownHeight" Value="504" />
@ -41,14 +51,13 @@
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> <Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Left" /> <Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Top" /> <Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="PlaceholderForeground" Value="{DynamicResource ComboBoxPlaceHolderForeground}" /> <Setter Property="PlaceholderForeground" Value="{DynamicResource ComboBoxPlaceHolderForeground}" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<DataValidationErrors> <DataValidationErrors>
<Grid RowDefinitions="Auto, *, Auto" <Grid RowDefinitions="Auto, *, Auto" ColumnDefinitions="*,32">
ColumnDefinitions="*,32">
<ContentPresenter x:Name="HeaderContentPresenter" <ContentPresenter x:Name="HeaderContentPresenter"
Grid.Row="0" Grid.Row="0"
Grid.Column="0" Grid.Column="0"
@ -66,7 +75,6 @@
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}" CornerRadius="{TemplateBinding CornerRadius}"
MinWidth="{DynamicResource ComboBoxThemeMinWidth}" /> MinWidth="{DynamicResource ComboBoxThemeMinWidth}" />
<Border x:Name="HighlightBackground" <Border x:Name="HighlightBackground"
Grid.Row="1" Grid.Row="1"
Grid.Column="0" Grid.Column="0"
@ -74,7 +82,8 @@
Background="{DynamicResource ComboBoxBackgroundUnfocused}" Background="{DynamicResource ComboBoxBackgroundUnfocused}"
BorderBrush="{DynamicResource ComboBoxBackgroundBorderBrushUnfocused}" BorderBrush="{DynamicResource ComboBoxBackgroundBorderBrushUnfocused}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}" /> CornerRadius="{TemplateBinding CornerRadius}"
IsVisible="False"/>
<TextBlock x:Name="PlaceholderTextBlock" <TextBlock x:Name="PlaceholderTextBlock"
Grid.Row="1" Grid.Row="1"
Grid.Column="0" Grid.Column="0"
@ -111,7 +120,9 @@
Width="12" Width="12"
Margin="0,0,10,0" Margin="0,0,10,0"
HorizontalAlignment="Right" HorizontalAlignment="Right"
VerticalAlignment="Center" /> VerticalAlignment="Center"
Foreground="{DynamicResource ComboBoxDropDownGlyphForeground}"
Data="M1939 486L2029 576L1024 1581L19 576L109 486L1024 1401L1939 486Z"/>
<Popup Name="PART_Popup" <Popup Name="PART_Popup"
WindowManagerAddShadowHint="False" WindowManagerAddShadowHint="False"
@ -125,7 +136,6 @@
Background="{DynamicResource ComboBoxDropDownBackground}" Background="{DynamicResource ComboBoxDropDownBackground}"
BorderBrush="{DynamicResource ComboBoxDropDownBorderBrush}" BorderBrush="{DynamicResource ComboBoxDropDownBorderBrush}"
BorderThickness="{DynamicResource ComboBoxDropdownBorderThickness}" BorderThickness="{DynamicResource ComboBoxDropdownBorderThickness}"
Margin="0,-1,0,-1"
Padding="{DynamicResource ComboBoxDropdownBorderPadding}" Padding="{DynamicResource ComboBoxDropdownBorderPadding}"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
CornerRadius="{DynamicResource OverlayCornerRadius}"> CornerRadius="{DynamicResource OverlayCornerRadius}">
@ -144,89 +154,73 @@
</DataValidationErrors> </DataValidationErrors>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style>
<!-- Normal State -->
<Style Selector="ComboBox /template/ TextBlock#PlaceholderTextBlock">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxPlaceHolderForeground}" />
</Style>
<Style Selector="ComboBox /template/ Border#HighlightBackground">
<Setter Property="IsVisible" Value="False" />
</Style>
<Style Selector="ComboBox /template/ PathIcon#DropDownGlyph">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxDropDownGlyphForeground}" />
<Setter Property="Data" Value="M1939 486L2029 576L1024 1581L19 576L109 486L1024 1401L1939 486Z" />
</Style>
<!-- PointerOver State -->
<Style Selector="ComboBox:pointerover /template/ Border#Background">
<Setter Property="Background" Value="{DynamicResource ComboBoxBackgroundPointerOver}" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxBorderBrushPointerOver}" />
</Style>
<!-- Pressed State -->
<Style Selector="ComboBox:pressed /template/ Border#Background">
<Setter Property="Background" Value="{DynamicResource ComboBoxBackgroundPressed}" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxBorderBrushPressed}" />
</Style>
<!-- Disabled State -->
<Style Selector="ComboBox:disabled /template/ Border#Background">
<Setter Property="Background" Value="{DynamicResource ComboBoxBackgroundDisabled}" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxBorderBrushDisabled}" />
</Style>
<Style Selector="ComboBox:disabled /template/ ContentPresenter#HeaderContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForegroundDisabled}" />
</Style>
<Style Selector="ComboBox:disabled /template/ ContentControl#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForegroundDisabled}" />
</Style>
<Style Selector="ComboBox:disabled /template/ TextBlock#PlaceholderTextBlock">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForegroundDisabled}" />
</Style>
<Style Selector="ComboBox:disabled /template/ PathIcon#DropDownGlyph">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxDropDownGlyphForegroundDisabled}" />
</Style>
<!-- Focused State -->
<Style Selector="ComboBox:focus-visible /template/ Border#HighlightBackground">
<Setter Property="IsVisible" Value="True" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxBackgroundBorderBrushFocused}" />
</Style>
<Style Selector="ComboBox:focus-visible /template/ ContentControl#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForegroundFocused}" />
</Style>
<Style Selector="ComboBox:focus-visible /template/ TextBlock#PlaceholderTextBlock">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForegroundFocused}" />
</Style>
<Style Selector="ComboBox:focus-visible /template/ PathIcon#DropDownGlyph">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxDropDownGlyphForegroundFocused}" />
</Style>
<!-- Focus Pressed State -->
<Style Selector="ComboBox:focused:pressed /template/ ContentControl#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForegroundFocusedPressed}" />
</Style>
<Style Selector="ComboBox:focused:pressed /template/ TextBlock#PlaceholderTextBlock">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxPlaceHolderForegroundFocusedPressed}" />
</Style>
<Style Selector="ComboBox:focused:pressed /template/ PathIcon#DropDownGlyph"> <!-- PointerOver State -->
<Setter Property="Foreground" Value="{DynamicResource ComboBoxDropDownGlyphForegroundFocusedPressed}" /> <Style Selector="^:pointerover /template/ Border#Background">
</Style> <Setter Property="Background" Value="{DynamicResource ComboBoxBackgroundPointerOver}" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxBorderBrushPointerOver}" />
<!-- Error State --> </Style>
<Style Selector="ComboBox:error /template/ Border#Background">
<Setter Property="BorderBrush" Value="{DynamicResource SystemControlErrorTextForegroundBrush}"/> <!-- Pressed State -->
</Style> <Style Selector="^:pressed /template/ Border#Background">
</Styles> <Setter Property="Background" Value="{DynamicResource ComboBoxBackgroundPressed}" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxBorderBrushPressed}" />
</Style>
<!-- Error State -->
<Style Selector="^:error /template/ Border#Background">
<Setter Property="BorderBrush" Value="{DynamicResource SystemControlErrorTextForegroundBrush}" />
</Style>
<!-- Focus Pressed State -->
<Style Selector="^:focused:pressed">
<Style Selector="^ /template/ ContentControl#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForegroundFocusedPressed}" />
</Style>
<Style Selector="^ /template/ TextBlock#PlaceholderTextBlock">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxPlaceHolderForegroundFocusedPressed}" />
</Style>
<Style Selector="^ /template/ PathIcon#DropDownGlyph">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxDropDownGlyphForegroundFocusedPressed}" />
</Style>
</Style>
<!-- Focused State -->
<Style Selector="^:focus-visible">
<Style Selector="^ /template/ Border#HighlightBackground">
<Setter Property="IsVisible" Value="True" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxBackgroundBorderBrushFocused}" />
</Style>
<Style Selector="^ /template/ ContentControl#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForegroundFocused}" />
</Style>
<Style Selector="^ /template/ TextBlock#PlaceholderTextBlock">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForegroundFocused}" />
</Style>
<Style Selector="^ /template/ PathIcon#DropDownGlyph">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxDropDownGlyphForegroundFocused}" />
</Style>
</Style>
<!-- Disabled State -->
<Style Selector="^:disabled">
<Style Selector="^ /template/ Border#Background">
<Setter Property="Background" Value="{DynamicResource ComboBoxBackgroundDisabled}" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxBorderBrushDisabled}" />
</Style>
<Style Selector="^ /template/ ContentPresenter#HeaderContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForegroundDisabled}" />
</Style>
<Style Selector="^ /template/ ContentControl#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForegroundDisabled}" />
</Style>
<Style Selector="^ /template/ TextBlock#PlaceholderTextBlock">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForegroundDisabled}" />
</Style>
<Style Selector="^ /template/ PathIcon#DropDownGlyph">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxDropDownGlyphForegroundDisabled}" />
</Style>
</Style>
</ControlTheme>
</ResourceDictionary>

106
src/Avalonia.Themes.Fluent/Controls/ComboBoxItem.xaml

@ -1,23 +1,20 @@
<Styles xmlns="https://github.com/avaloniaui"> <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith> <Design.PreviewWith>
<Border Padding="20"> <Border Padding="20">
<Border Background="{DynamicResource ComboBoxDropDownBackground}" <Border Background="{DynamicResource ComboBoxDropDownBackground}" BorderBrush="{DynamicResource ComboBoxDropDownBorderBrush}" BorderThickness="{DynamicResource ComboBoxDropdownBorderThickness}" Margin="0,-1,0,-1" Padding="{DynamicResource ComboBoxDropdownBorderPadding}" CornerRadius="{DynamicResource OverlayCornerRadius}">
BorderBrush="{DynamicResource ComboBoxDropDownBorderBrush}"
BorderThickness="{DynamicResource ComboBoxDropdownBorderThickness}"
Margin="0,-1,0,-1"
Padding="{DynamicResource ComboBoxDropdownBorderPadding}"
CornerRadius="{DynamicResource OverlayCornerRadius}">
<StackPanel HorizontalAlignment="Stretch"> <StackPanel HorizontalAlignment="Stretch">
<ComboBoxItem>Item 1</ComboBoxItem> <ComboBoxItem>Item 1</ComboBoxItem>
<ComboBoxItem>Item 2 long</ComboBoxItem> <ComboBoxItem>Item 2 long</ComboBoxItem>
<ComboBoxItem IsSelected="True">Item 3</ComboBoxItem> <ComboBoxItem IsSelected="True">Item 3</ComboBoxItem>
<ComboBoxItem IsEnabled="False">Item 4</ComboBoxItem> <ComboBoxItem IsEnabled="False">Item 4</ComboBoxItem>
<ComboBoxItem IsSelected="True" IsEnabled="False">Item 5</ComboBoxItem>
</StackPanel> </StackPanel>
</Border> </Border>
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Style Selector="ComboBoxItem"> <ControlTheme x:Key="{x:Type ComboBoxItem}" TargetType="ComboBoxItem">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForeground}" /> <Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForeground}" />
<Setter Property="Background" Value="{DynamicResource ComboBoxItemBackground}" /> <Setter Property="Background" Value="{DynamicResource ComboBoxItemBackground}" />
<Setter Property="Padding" Value="{DynamicResource ComboBoxItemThemePadding}" /> <Setter Property="Padding" Value="{DynamicResource ComboBoxItemThemePadding}" />
@ -37,54 +34,53 @@
Padding="{TemplateBinding Padding}" /> Padding="{TemplateBinding Padding}" />
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style>
<!-- PointerOver state --> <!-- PointerOver state -->
<Style Selector="ComboBoxItem:pointerover /template/ ContentPresenter"> <Style Selector="^:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ComboBoxItemBackgroundPointerOver}" /> <Setter Property="Background" Value="{DynamicResource ComboBoxItemBackgroundPointerOver}" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushPointerOver}" /> <Setter Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushPointerOver}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForegroundPointerOver}" /> <Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForegroundPointerOver}" />
</Style> </Style>
<!-- Disabled state --> <!-- Disabled state -->
<Style Selector="ComboBoxItem:disabled /template/ ContentPresenter"> <Style Selector="^:disabled /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ComboBoxItemBackgroundDisabled}" /> <Setter Property="Background" Value="{DynamicResource ComboBoxItemBackgroundDisabled}" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushDisabled}" /> <Setter Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushDisabled}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForegroundDisabled}" /> <Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForegroundDisabled}" />
</Style> </Style>
<!-- Pressed state --> <!-- Pressed state -->
<Style Selector="ComboBoxItem:pressed /template/ ContentPresenter"> <Style Selector="^:pressed /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ComboBoxItemBackgroundPressed}" /> <Setter Property="Background" Value="{DynamicResource ComboBoxItemBackgroundPressed}" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushPressed}" /> <Setter Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushPressed}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForegroundPressed}" /> <Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForegroundPressed}" />
</Style> </Style>
<!-- Selected state --> <!-- Selected state -->
<Style Selector="ComboBoxItem:selected /template/ ContentPresenter"> <Style Selector="^:selected">
<Setter Property="Background" Value="{DynamicResource ComboBoxItemBackgroundSelected}" /> <Style Selector="^ /template/ ContentPresenter">
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushSelected}" /> <Setter Property="Background" Value="{DynamicResource ComboBoxItemBackgroundSelected}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForegroundSelected}" /> <Setter Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushSelected}" />
</Style> <Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForegroundSelected}" />
</Style>
<!-- Selected Disabled state --> <!-- Selected Disabled state -->
<Style Selector="ComboBoxItem:selected:disabled /template/ ContentPresenter"> <Style Selector="^:disabled /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ComboBoxItemBackgroundSelectedDisabled}" /> <Setter Property="Background" Value="{DynamicResource ComboBoxItemBackgroundSelectedDisabled}" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushSelectedDisabled}" /> <Setter Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushSelectedDisabled}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForegroundSelectedDisabled}" /> <Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForegroundSelectedDisabled}" />
</Style> </Style>
<!-- Selected PointerOver state -->
<!-- Selected PointerOver state --> <Style Selector="^:pointerover /template/ ContentPresenter">
<Style Selector="ComboBoxItem:selected:pointerover /template/ ContentPresenter"> <Setter Property="Background" Value="{DynamicResource ComboBoxItemBackgroundSelectedPointerOver}" />
<Setter Property="Background" Value="{DynamicResource ComboBoxItemBackgroundSelectedPointerOver}" /> <Setter Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushSelectedPointerOver}" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushSelectedPointerOver}" /> <Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForegroundSelectedPointerOver}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForegroundSelectedPointerOver}" /> </Style>
</Style> <!-- Selected Pressed state -->
<Style Selector="^:pressed /template/ ContentPresenter">
<!-- Selected Pressed state --> <Setter Property="Background" Value="{DynamicResource ComboBoxItemBackgroundSelectedPressed}" />
<Style Selector="ComboBoxItem:selected:pressed /template/ ContentPresenter"> <Setter Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushSelectedPressed}" />
<Setter Property="Background" Value="{DynamicResource ComboBoxItemBackgroundSelectedPressed}" /> <Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForegroundSelectedPressed}" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushSelectedPressed}" /> </Style>
<Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForegroundSelectedPressed}" /> </Style>
</Style> </ControlTheme>
</Styles> </ResourceDictionary>

6
src/Avalonia.Themes.Fluent/Controls/Common.xaml

@ -1,6 +0,0 @@
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style Selector="TextBlock.CaptionTextBlockStyle">
<Setter Property="FontSize" Value="12" />
<Setter Property="FontWeight" Value="Normal" />
</Style>
</Styles>

35
src/Avalonia.Themes.Fluent/Controls/ContentControl.xaml

@ -1,16 +1,19 @@
<Style xmlns="https://github.com/avaloniaui" Selector="ContentControl"> <ResourceDictionary xmlns="https://github.com/avaloniaui"
<Setter Property="Template"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTemplate> <ControlTheme x:Key="{x:Type ContentControl}" TargetType="ContentControl">
<ContentPresenter Name="PART_ContentPresenter" <Setter Property="Template">
Background="{TemplateBinding Background}" <ControlTemplate>
BorderBrush="{TemplateBinding BorderBrush}" <ContentPresenter Name="PART_ContentPresenter"
BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"
CornerRadius="{TemplateBinding CornerRadius}" BorderBrush="{TemplateBinding BorderBrush}"
ContentTemplate="{TemplateBinding ContentTemplate}" BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}" CornerRadius="{TemplateBinding CornerRadius}"
Padding="{TemplateBinding Padding}" ContentTemplate="{TemplateBinding ContentTemplate}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"/> Padding="{TemplateBinding Padding}"
</ControlTemplate> VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
</Setter> HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"/>
</Style> </ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>

84
src/Avalonia.Themes.Fluent/Controls/ContextMenu.xaml

@ -1,6 +1,5 @@
<Style xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
Selector="ContextMenu">
<Design.PreviewWith> <Design.PreviewWith>
<Border Background="{DynamicResource SystemAccentColor}" <Border Background="{DynamicResource SystemAccentColor}"
Margin="16" Margin="16"
@ -10,8 +9,7 @@
<Border.ContextMenu> <Border.ContextMenu>
<ContextMenu> <ContextMenu>
<MenuItem Header="Standard _Menu Item" /> <MenuItem Header="Standard _Menu Item" />
<MenuItem Header="Disabled" <MenuItem Header="Disabled" IsEnabled="False" />
IsEnabled="False" />
<Separator /> <Separator />
<MenuItem Header="Menu with _Submenu"> <MenuItem Header="Menu with _Submenu">
<MenuItem Header="Submenu _1" /> <MenuItem Header="Submenu _1" />
@ -31,42 +29,42 @@
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Style.Resources> <!-- Added missing resource -->
<!-- Added missing resource --> <Thickness x:Key="MenuFlyoutScrollerMargin">0,4,0,4</Thickness>
<Thickness x:Key="MenuFlyoutScrollerMargin">0,4,0,4</Thickness>
</Style.Resources>
<Setter Property="Background" Value="{DynamicResource MenuFlyoutPresenterBackground}" /> <ControlTheme x:Key="{x:Type ContextMenu}" TargetType="ContextMenu">
<Setter Property="BorderBrush" Value="{DynamicResource MenuFlyoutPresenterBorderBrush}" /> <Setter Property="Background" Value="{DynamicResource MenuFlyoutPresenterBackground}" />
<Setter Property="BorderThickness" Value="{DynamicResource MenuFlyoutPresenterBorderThemeThickness}" /> <Setter Property="BorderBrush" Value="{DynamicResource MenuFlyoutPresenterBorderBrush}" />
<Setter Property="CornerRadius" Value="{DynamicResource OverlayCornerRadius}" /> <Setter Property="BorderThickness" Value="{DynamicResource MenuFlyoutPresenterBorderThemeThickness}" />
<Setter Property="MaxWidth" Value="{DynamicResource FlyoutThemeMaxWidth}" /> <Setter Property="CornerRadius" Value="{DynamicResource OverlayCornerRadius}" />
<Setter Property="MinHeight" Value="{DynamicResource MenuFlyoutThemeMinHeight}" /> <Setter Property="MaxWidth" Value="{DynamicResource FlyoutThemeMaxWidth}" />
<Setter Property="Padding" Value="{DynamicResource MenuFlyoutPresenterThemePadding}" /> <Setter Property="MinHeight" Value="{DynamicResource MenuFlyoutThemeMinHeight}" />
<Setter Property="HorizontalAlignment" Value="Stretch" /> <Setter Property="Padding" Value="{DynamicResource MenuFlyoutPresenterThemePadding}" />
<Setter Property="TextBlock.FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> <Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="TextBlock.FontWeight" Value="Normal" /> <Setter Property="TextBlock.FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="WindowManagerAddShadowHint" Value="False" /> <Setter Property="TextBlock.FontWeight" Value="Normal" />
<Setter Property="Template"> <Setter Property="WindowManagerAddShadowHint" Value="False" />
<ControlTemplate> <Setter Property="Template">
<Border Background="{TemplateBinding Background}" <ControlTemplate>
BorderBrush="{TemplateBinding BorderBrush}" <Border Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}"
Padding="{TemplateBinding Padding}" BorderThickness="{TemplateBinding BorderThickness}"
MaxWidth="{TemplateBinding MaxWidth}" Padding="{TemplateBinding Padding}"
MinHeight="{TemplateBinding MinHeight}" MaxWidth="{TemplateBinding MaxWidth}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}" MinHeight="{TemplateBinding MinHeight}"
CornerRadius="{TemplateBinding CornerRadius}"> HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
<ScrollViewer Classes="menuscroller"> CornerRadius="{TemplateBinding CornerRadius}">
<ItemsPresenter Name="PART_ItemsPresenter" <ScrollViewer Classes="menuscroller">
Items="{TemplateBinding Items}" <ItemsPresenter Name="PART_ItemsPresenter"
ItemsPanel="{TemplateBinding ItemsPanel}" Items="{TemplateBinding Items}"
ItemTemplate="{TemplateBinding ItemTemplate}" ItemsPanel="{TemplateBinding ItemsPanel}"
Margin="{DynamicResource MenuFlyoutScrollerMargin}" ItemTemplate="{TemplateBinding ItemTemplate}"
KeyboardNavigation.TabNavigation="Continue" Margin="{DynamicResource MenuFlyoutScrollerMargin}"
Grid.IsSharedSizeScope="True" /> KeyboardNavigation.TabNavigation="Continue"
</ScrollViewer> Grid.IsSharedSizeScope="True" />
</Border> </ScrollViewer>
</ControlTemplate> </Border>
</Setter> </ControlTemplate>
</Style> </Setter>
</ControlTheme>
</ResourceDictionary>

21
src/Avalonia.Themes.Fluent/Controls/DataValidationErrors.xaml

@ -1,8 +1,8 @@
<Styles xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="using:System" xmlns:sys="using:System"
x:CompileBindings="True" x:CompileBindings="True"
x:DataType="DataValidationErrors"> x:DataType="DataValidationErrors">
<Design.PreviewWith> <Design.PreviewWith>
<Border Padding="20"> <Border Padding="20">
<StackPanel Spacing="20"> <StackPanel Spacing="20">
@ -26,8 +26,8 @@
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Style Selector="DataValidationErrors"> <ControlTheme x:Key="{x:Type DataValidationErrors}" TargetType="DataValidationErrors">
<Style.Resources> <ControlTheme.Resources>
<DataTemplate x:Key="InlineDataValidationErrorTemplate"> <DataTemplate x:Key="InlineDataValidationErrorTemplate">
<ItemsControl Items="{Binding}" x:DataType="DataValidationErrors" Foreground="{DynamicResource SystemControlErrorTextForegroundBrush}"> <ItemsControl Items="{Binding}" x:DataType="DataValidationErrors" Foreground="{DynamicResource SystemControlErrorTextForegroundBrush}">
<ItemsControl.Styles> <ItemsControl.Styles>
@ -96,9 +96,8 @@
ContentTemplate="{TemplateBinding ContentTemplate}" /> ContentTemplate="{TemplateBinding ContentTemplate}" />
</DockPanel> </DockPanel>
</ControlTemplate> </ControlTemplate>
</Style.Resources> </ControlTheme.Resources>
<Setter Property="Template" Value="{StaticResource InlineDataValidationContentTemplate}" /> <Setter Property="Template" Value="{StaticResource InlineDataValidationContentTemplate}" />
<Setter Property="ErrorTemplate" Value="{StaticResource InlineDataValidationErrorTemplate}" /> <Setter Property="ErrorTemplate" Value="{StaticResource InlineDataValidationErrorTemplate}" />
</Style> </ControlTheme>
</Styles> </ResourceDictionary>

332
src/Avalonia.Themes.Fluent/Controls/DatePicker.xaml

@ -5,125 +5,81 @@
// All other rights reserved. // All other rights reserved.
--> -->
<Styles xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=netstandard" xmlns:sys="clr-namespace:System;assembly=netstandard"
x:CompileBindings="True"> x:CompileBindings="True">
<Design.PreviewWith> <Design.PreviewWith>
<Border Padding="20"> <Border Padding="20" Height="500">
<DatePicker CornerRadius="10" /> <StackPanel Spacing="20" VerticalAlignment="Center">
<DatePicker />
<DatePicker CornerRadius="10" />
<DatePicker IsEnabled="False" />
<DatePicker>
<DataValidationErrors.Error>
<sys:Exception>
<x:Arguments>
<x:String>Error</x:String>
</x:Arguments>
</sys:Exception>
</DataValidationErrors.Error>
</DatePicker>
</StackPanel>
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Styles.Resources>
<Thickness x:Key="DatePickerTopHeaderMargin">0,0,0,4</Thickness>
<x:Double x:Key="DatePickerFlyoutPresenterHighlightHeight">40</x:Double>
<x:Double x:Key="DatePickerFlyoutPresenterItemHeight">40</x:Double>
<x:Double x:Key="DatePickerFlyoutPresenterAcceptDismissHostGridHeight">41</x:Double>
<x:Double x:Key="DatePickerThemeMinWidth">296</x:Double>
<x:Double x:Key="DatePickerThemeMaxWidth">456</x:Double>
<Thickness x:Key="DatePickerFlyoutPresenterItemPadding">0,3,0,6</Thickness>
<Thickness x:Key="DatePickerFlyoutPresenterMonthPadding">9,3,0,6</Thickness>
<Thickness x:Key="DatePickerHostPadding">0,3,0,6</Thickness>
<Thickness x:Key="DatePickerHostMonthPadding">9,3,0,6</Thickness>
<x:Double x:Key="DatePickerSpacerThemeWidth">1</x:Double>
</Styles.Resources>
<!-- Styles for the items displayed in the selectors -->
<Style Selector="ListBoxItem.DateTimePickerItem">
<Setter Property="Padding" Value="{DynamicResource DatePickerFlyoutPresenterItemPadding}"/>
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
</Style>
<Style Selector="ListBoxItem.DateTimePickerItem:selected">
<Setter Property="IsHitTestVisible" Value="False"/>
</Style>
<Style Selector="ListBoxItem.DateTimePickerItem:selected /template/ Rectangle#PressedBackground">
<Setter Property="Fill" Value="Transparent"/>
</Style>
<Style Selector="ListBoxItem.DateTimePickerItem:selected /template/ ContentPresenter">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}"/>
</Style>
<Style Selector="ListBoxItem.DateTimePickerItem.MonthItem">
<Setter Property="Padding" Value="{DynamicResource DatePickerFlyoutPresenterMonthPadding}"/>
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
</Style>
<Thickness x:Key="DatePickerTopHeaderMargin">0,0,0,4</Thickness>
<x:Double x:Key="DatePickerFlyoutPresenterHighlightHeight">40</x:Double>
<x:Double x:Key="DatePickerFlyoutPresenterItemHeight">40</x:Double>
<x:Double x:Key="DatePickerFlyoutPresenterAcceptDismissHostGridHeight">41</x:Double>
<x:Double x:Key="DatePickerThemeMinWidth">296</x:Double>
<x:Double x:Key="DatePickerThemeMaxWidth">456</x:Double>
<Thickness x:Key="DatePickerFlyoutPresenterItemPadding">0,3,0,6</Thickness>
<Thickness x:Key="DatePickerFlyoutPresenterMonthPadding">9,3,0,6</Thickness>
<Thickness x:Key="DatePickerHostPadding">0,3,0,6</Thickness>
<Thickness x:Key="DatePickerHostMonthPadding">9,3,0,6</Thickness>
<x:Double x:Key="DatePickerSpacerThemeWidth">1</x:Double>
<!-- This is used for both the accept/dismiss & repeatbuttons in the presenter--> <ControlTheme x:Key="FluentDatePickerFlyoutButton" TargetType="Button">
<Style Selector=":is(Button).DateTimeFlyoutButtonStyle"> <Setter Property="RenderTransform" Value="none" />
<Setter Property="Background" Value="{DynamicResource DateTimePickerFlyoutButtonBackground}" />
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<!-- <ContentPresenter Name="PART_ContentPresenter"
The background is doubled here for the loopingselector up/down repeat buttons BorderBrush="{TemplateBinding BorderBrush}"
that appear opaque. Not sure how MS does it though I suspect this is it Background="{TemplateBinding Background}"
but source isn't MIT yet, so this is my solution --> BorderThickness="{TemplateBinding BorderThickness}"
<Border Background="{TemplateBinding Background}"> Content="{TemplateBinding Content}"
<ContentPresenter x:Name="ContentPresenter" Foreground="{TemplateBinding Foreground}"
Background="{TemplateBinding Background}" HorizontalContentAlignment="Stretch"
BorderBrush="{DynamicResource DateTimePickerFlyoutButtonBorderBrush}" VerticalContentAlignment="Stretch"
BorderThickness="{DynamicResource DateTimeFlyoutButtonBorderThickness}" CornerRadius="{TemplateBinding CornerRadius}"/>
Content="{TemplateBinding Content}"
Foreground="{DynamicResource SystemControlHighlightAltBaseHighBrush}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
CornerRadius="{TemplateBinding CornerRadius}"/>
</Border>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style>
<Style Selector="^:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Style Selector=":is(Button).DateTimeFlyoutButtonStyle:pointerover /template/ ContentPresenter"> <Setter Property="BorderBrush" Value="{DynamicResource DatePickerButtonBorderBrushPointerOver}"/>
<Setter Property="Background" Value="{DynamicResource DateTimePickerFlyoutButtonBackgroundPointerOver}"/> <Setter Property="Background" Value="{DynamicResource DatePickerButtonBackgroundPointerOver}"/>
<Setter Property="BorderBrush" Value="{DynamicResource DateTimePickerFlyoutButtonBorderBrushPointerOver}"/> <Setter Property="Foreground" Value="{DynamicResource DatePickerButtonForegroundPointerOver}"/>
<Setter Property="Foreground" Value="{DynamicResource DateTimePickerFlyoutButtonForegroundPointerOver}"/> </Style>
</Style>
<Style Selector="^:pressed">
<Setter Property="RenderTransform" Value="scale(0.98)" />
</Style>
<Style Selector="^:pressed /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="BorderBrush" Value="{DynamicResource DatePickerButtonBorderBrushPressed}"/>
<Setter Property="Background" Value="{DynamicResource DatePickerButtonBackgroundPressed}"/>
<Setter Property="Foreground" Value="{DynamicResource DatePickerButtonForegroundPressed}"/>
</Style>
<Style Selector=":is(Button).DateTimeFlyoutButtonStyle:pressed /template/ ContentPresenter"> <Style Selector="^:disabled /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource DateTimePickerFlyoutButtonBackgroundPressed}"/> <Setter Property="BorderBrush" Value="{DynamicResource DatePickerButtonBorderBrushDisabled}"/>
<Setter Property="BorderBrush" Value="{DynamicResource DateTimePickerFlyoutButtonBorderBrushPressed}"/> <Setter Property="Background" Value="{DynamicResource DatePickerButtonBackgroundDisabled}"/>
<Setter Property="Foreground" Value="{DynamicResource DateTimePickerFlyoutButtonForegroundPressed}"/> <Setter Property="Foreground" Value="{DynamicResource DatePickerButtonForegroundDisabled}"/>
</Style> </Style>
</ControlTheme>
<Style Selector="RepeatButton.UpButton"> <ControlTheme x:Key="{x:Type DatePicker}" TargetType="DatePicker">
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="Height" Value="22" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Focusable" Value="False" />
<Setter Property="Background" Value="{DynamicResource SystemControlBackgroundChromeMediumLowBrush}" />
<Setter Property="Content">
<Template>
<Viewbox Height="10" Width="10" HorizontalAlignment="Center" VerticalAlignment="Center">
<Path Stroke="{Binding $parent[RepeatButton].Foreground}" StrokeThickness="1" Data="M 0,9 L 9,0 L 18,9"/>
</Viewbox>
</Template>
</Setter>
</Style>
<Style Selector="RepeatButton.DownButton">
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Height" Value="22" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Focusable" Value="False" />
<Setter Property="Background" Value="{DynamicResource SystemControlBackgroundChromeMediumLowBrush}" />
<Setter Property="Content">
<Template>
<Viewbox Height="10" Width="10" HorizontalAlignment="Center" VerticalAlignment="Center">
<Path Stroke="{Binding $parent[RepeatButton].Foreground}" StrokeThickness="1" Data="M 0,0 L 9,9 L 18,0"/>
</Viewbox>
</Template>
</Setter>
</Style>
<Style Selector="DatePicker">
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="Foreground" Value="{DynamicResource DatePickerButtonForeground}" /> <Setter Property="Foreground" Value="{DynamicResource DatePickerButtonForeground}" />
<Setter Property="Background" Value="{DynamicResource DatePickerButtonBackground}"/> <Setter Property="Background" Value="{DynamicResource DatePickerButtonBackground}"/>
@ -138,13 +94,16 @@
<Grid Name="LayoutRoot" Margin="{TemplateBinding Padding}" RowDefinitions="Auto,*"> <Grid Name="LayoutRoot" Margin="{TemplateBinding Padding}" RowDefinitions="Auto,*">
<ContentPresenter Name="HeaderContentPresenter" Grid.Row="0" <ContentPresenter Name="HeaderContentPresenter" Grid.Row="0"
Content="{TemplateBinding Header}" Content="{TemplateBinding Header}"
Foreground="{DynamicResource DatePickerHeaderForeground}"
ContentTemplate="{TemplateBinding HeaderTemplate}" ContentTemplate="{TemplateBinding HeaderTemplate}"
Margin="{DynamicResource DatePickerTopHeaderMargin}" Margin="{DynamicResource DatePickerTopHeaderMargin}"
MaxWidth="{DynamicResource DatePickerThemeMaxWidth}" MaxWidth="{DynamicResource DatePickerThemeMaxWidth}"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
VerticalAlignment="Top"/> VerticalAlignment="Top"/>
<Button Name="FlyoutButton" Grid.Row="1" <Button Name="FlyoutButton"
Grid.Row="1"
Theme="{StaticResource FluentDatePickerFlyoutButton}"
Foreground="{TemplateBinding Foreground}" Foreground="{TemplateBinding Foreground}"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
@ -155,22 +114,7 @@
MaxWidth="{DynamicResource DatePickerThemeMaxWidth}" MaxWidth="{DynamicResource DatePickerThemeMaxWidth}"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" VerticalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
TemplatedControl.IsTemplateFocusTarget="True"> TemplatedControl.IsTemplateFocusTarget="True">
<Button.Template>
<ControlTemplate>
<ContentPresenter Name="ContentPresenter"
BorderBrush="{TemplateBinding BorderBrush}"
Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
Foreground="{TemplateBinding Foreground}"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
CornerRadius="{TemplateBinding CornerRadius}"/>
</ControlTemplate>
</Button.Template>
<Grid Name="ButtonContentGrid" ColumnDefinitions="78*,Auto,132*,Auto,78*"> <Grid Name="ButtonContentGrid" ColumnDefinitions="78*,Auto,132*,Auto,78*">
<TextBlock Name="DayText" Text="day" HorizontalAlignment="Center" <TextBlock Name="DayText" Text="day" HorizontalAlignment="Center"
Padding="{DynamicResource DatePickerHostPadding}" Padding="{DynamicResource DatePickerHostPadding}"
@ -210,47 +154,26 @@
</DataValidationErrors> </DataValidationErrors>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style>
<Style Selector="DatePicker /template/ ContentPresenter#HeaderContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource DatePickerHeaderForeground}"/>
</Style>
<Style Selector="DatePicker:disabled /template/ Rectangle">
<Setter Property="Fill" Value="{DynamicResource DatePickerSpacerFillDisabled}"/>
</Style>
<Style Selector="DatePicker /template/ Button#FlyoutButton:pointerover /template/ ContentPresenter">
<Setter Property="BorderBrush" Value="{DynamicResource DatePickerButtonBorderBrushPointerOver}"/>
<Setter Property="Background" Value="{DynamicResource DatePickerButtonBackgroundPointerOver}"/>
<Setter Property="Foreground" Value="{DynamicResource DatePickerButtonForegroundPointerOver}"/>
</Style>
<Style Selector="DatePicker /template/ Button#FlyoutButton:pressed /template/ ContentPresenter">
<Setter Property="BorderBrush" Value="{DynamicResource DatePickerButtonBorderBrushPressed}"/>
<Setter Property="Background" Value="{DynamicResource DatePickerButtonBackgroundPressed}"/>
<Setter Property="Foreground" Value="{DynamicResource DatePickerButtonForegroundPressed}"/>
</Style>
<Style Selector="DatePicker /template/ Button#FlyoutButton:disabled /template/ ContentPresenter"> <Style Selector="^:disabled /template/ Rectangle">
<Setter Property="BorderBrush" Value="{DynamicResource DatePickerButtonBorderBrushDisabled}"/> <Setter Property="Fill" Value="{DynamicResource DatePickerSpacerFillDisabled}"/>
<Setter Property="Background" Value="{DynamicResource DatePickerButtonBackgroundDisabled}"/> </Style>
<Setter Property="Foreground" Value="{DynamicResource DatePickerButtonForegroundDisabled}"/>
</Style>
<!-- Changes foreground for watermark text when SelectedDate is null--> <!-- Changes foreground for watermark text when SelectedDate is null-->
<Style Selector="DatePicker:hasnodate /template/ Button#FlyoutButton TextBlock"> <Style Selector="^:hasnodate /template/ Button#FlyoutButton TextBlock">
<Setter Property="Foreground" Value="{DynamicResource TextControlPlaceholderForeground}"/> <Setter Property="Foreground" Value="{DynamicResource TextControlPlaceholderForeground}"/>
</Style> </Style>
<Style Selector="DatePicker:error /template/ Button#FlyoutButton /template/ ContentPresenter"> <Style Selector="^:error /template/ Button#FlyoutButton">
<Setter Property="BorderBrush" Value="{DynamicResource SystemControlErrorTextForegroundBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource SystemControlErrorTextForegroundBrush}"/>
</Style> </Style>
</ControlTheme>
<!--WinUI: DatePickerFlyoutPresenter--> <!--WinUI: DatePickerFlyoutPresenter-->
<Style Selector="DatePickerPresenter"> <ControlTheme x:Key="{x:Type DatePickerPresenter}" TargetType="DatePickerPresenter">
<Setter Property="Width" Value="296" /> <Setter Property="Width" Value="296" />
<Setter Property="MinWidth" Value="296" /> <Setter Property="MinWidth" Value="296" />
<Setter Property="MaxHeight" Value="398" /> <Setter Property="MaxHeight" Value="398" />
<Setter Property="FontWeight" Value="Normal" /> <Setter Property="FontWeight" Value="Normal" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="Background" Value="{DynamicResource DatePickerFlyoutPresenterBackground}" /> <Setter Property="Background" Value="{DynamicResource DatePickerFlyoutPresenterBackground}" />
@ -266,45 +189,44 @@
MaxHeight="398" CornerRadius="{TemplateBinding CornerRadius}"> MaxHeight="398" CornerRadius="{TemplateBinding CornerRadius}">
<Grid Name="ContentRoot" RowDefinitions="*,Auto"> <Grid Name="ContentRoot" RowDefinitions="*,Auto">
<Grid Name="PickerContainer"> <Grid Name="PickerContainer">
<Grid.Styles>
<Style Selector="DateTimePickerPanel > ListBoxItem">
<Setter Property="Theme" Value="{StaticResource FluentDateTimePickerItem}" />
</Style>
</Grid.Styles>
<!--Column Definitions set in code, ignore here--> <!--Column Definitions set in code, ignore here-->
<Panel Name="MonthHost"> <Panel Name="MonthHost">
<ScrollViewer HorizontalScrollBarVisibility="Disabled" <ScrollViewer HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Hidden"> VerticalScrollBarVisibility="Hidden">
<DateTimePickerPanel Name="MonthSelector" <DateTimePickerPanel Name="MonthSelector"
PanelType="Month" PanelType="Month"
ItemHeight="{DynamicResource DatePickerFlyoutPresenterItemHeight}" ItemHeight="{DynamicResource DatePickerFlyoutPresenterItemHeight}"
ShouldLoop="True" /> ShouldLoop="True" />
</ScrollViewer> </ScrollViewer>
<RepeatButton Name="MonthUpButton" <RepeatButton Name="MonthUpButton" Theme="{StaticResource FluentDateTimePickerUpButton}"/>
Classes="DateTimeFlyoutButtonStyle UpButton"/> <RepeatButton Name="MonthDownButton" Theme="{StaticResource FluentDateTimePickerDownButton}"/>
<RepeatButton Name="MonthDownButton"
Classes="DateTimeFlyoutButtonStyle DownButton"/>
</Panel> </Panel>
<Panel Name="DayHost"> <Panel Name="DayHost">
<ScrollViewer HorizontalScrollBarVisibility="Disabled" <ScrollViewer HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Hidden"> VerticalScrollBarVisibility="Hidden">
<DateTimePickerPanel Name="DaySelector" <DateTimePickerPanel Name="DaySelector"
PanelType="Day" PanelType="Day"
ItemHeight="{DynamicResource DatePickerFlyoutPresenterItemHeight}" ItemHeight="{DynamicResource DatePickerFlyoutPresenterItemHeight}"
ShouldLoop="True" /> ShouldLoop="True" />
</ScrollViewer> </ScrollViewer>
<RepeatButton Name="DayUpButton" <RepeatButton Name="DayUpButton" Theme="{StaticResource FluentDateTimePickerUpButton}"/>
Classes="DateTimeFlyoutButtonStyle UpButton"/> <RepeatButton Name="DayDownButton" Theme="{StaticResource FluentDateTimePickerDownButton}"/>
<RepeatButton Name="DayDownButton"
Classes="DateTimeFlyoutButtonStyle DownButton"/>
</Panel> </Panel>
<Panel Name="YearHost"> <Panel Name="YearHost">
<ScrollViewer HorizontalScrollBarVisibility="Disabled" <ScrollViewer HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Hidden"> VerticalScrollBarVisibility="Hidden">
<DateTimePickerPanel Name="YearSelector" <DateTimePickerPanel Name="YearSelector"
PanelType="Year" PanelType="Year"
ItemHeight="{DynamicResource DatePickerFlyoutPresenterItemHeight}" ItemHeight="{DynamicResource DatePickerFlyoutPresenterItemHeight}"
ShouldLoop="False" /> ShouldLoop="False" />
</ScrollViewer> </ScrollViewer>
<RepeatButton Name="YearUpButton" <RepeatButton Name="YearUpButton" Theme="{StaticResource FluentDateTimePickerUpButton}"/>
Classes="DateTimeFlyoutButtonStyle UpButton"/> <RepeatButton Name="YearDownButton" Theme="{StaticResource FluentDateTimePickerDownButton}"/>
<RepeatButton Name="YearDownButton"
Classes="DateTimeFlyoutButtonStyle DownButton"/>
</Panel> </Panel>
<Rectangle Name="HighlightRect" IsHitTestVisible="False" ZIndex="-1" <Rectangle Name="HighlightRect" IsHitTestVisible="False" ZIndex="-1"
Fill="{DynamicResource DatePickerFlyoutPresenterHighlightFill}" Fill="{DynamicResource DatePickerFlyoutPresenterHighlightFill}"
@ -321,34 +243,48 @@
Width="{DynamicResource DatePickerSpacerThemeWidth}" Width="{DynamicResource DatePickerSpacerThemeWidth}"
Grid.Column="3" /> Grid.Column="3" />
</Grid> </Grid>
<Grid Grid.Row="1" Height="{DynamicResource DatePickerFlyoutPresenterAcceptDismissHostGridHeight}"
Name="AcceptDismissGrid" ColumnDefinitions="*,*"> <Grid Name="AcceptDismissGrid"
<Rectangle Height="{DynamicResource DatePickerSpacerThemeWidth}" VerticalAlignment="Top" Grid.Row="1"
ColumnDefinitions="*,*">
<Rectangle Height="{DynamicResource DatePickerSpacerThemeWidth}"
VerticalAlignment="Top"
Fill="{DynamicResource DatePickerFlyoutPresenterSpacerFill}" Fill="{DynamicResource DatePickerFlyoutPresenterSpacerFill}"
Grid.ColumnSpan="2"/> Grid.ColumnSpan="2"/>
<Button Name="AcceptButton" Grid.Column="0" Classes="DateTimeFlyoutButtonStyle" <Button Name="AcceptButton"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> Grid.Column="0"
<Path Stroke="{Binding $parent[Button].Foreground}" StrokeLineCap="Round" Theme="{StaticResource FluentDateTimePickerButton}"
StrokeThickness="0.75" Data="M0.5,8.5 5,13.5 15.5,3" /> Height="{DynamicResource DatePickerFlyoutPresenterAcceptDismissHostGridHeight}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<Path Stroke="{Binding $parent[Button].Foreground}"
StrokeLineCap="Round"
StrokeThickness="0.75"
Data="M0.5,8.5 5,13.5 15.5,3" />
</Button> </Button>
<Button Name="DismissButton" Grid.Column="1" Classes="DateTimeFlyoutButtonStyle" <Button Name="DismissButton"
FontSize="16" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> Grid.Column="1"
<Path Stroke="{Binding $parent[Button].Foreground}" StrokeLineCap="Round" Theme="{StaticResource FluentDateTimePickerButton}"
StrokeThickness="0.75" Data="M2,2 14,14 M2,14 14 2" /> Height="{DynamicResource DatePickerFlyoutPresenterAcceptDismissHostGridHeight}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<Path Stroke="{Binding $parent[Button].Foreground}"
StrokeLineCap="Round"
StrokeThickness="0.75"
Data="M2,2 14,14 M2,14 14 2" />
</Button> </Button>
</Grid> </Grid>
</Grid> </Grid>
</Border> </Border>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style>
<Style Selector="DatePickerPresenter /template/ Panel RepeatButton"> <Style Selector="^ /template/ Panel">
<Setter Property="IsVisible" Value="False" /> <Style Selector="^:pointerover RepeatButton">
</Style> <Setter Property="IsVisible" Value="True" />
</Style>
</Style>
</ControlTheme>
<Style Selector="DatePickerPresenter /template/ Panel:pointerover RepeatButton">
<Setter Property="IsVisible" Value="True" /> </ResourceDictionary>
</Style>
</Styles>

118
src/Avalonia.Themes.Fluent/Controls/DateTimePickerShared.xaml

@ -0,0 +1,118 @@
<!--
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
-->
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=netstandard"
x:CompileBindings="True">
<Design.PreviewWith>
<Border Padding="20" Width="200">
<StackPanel Spacing="20">
<ListBoxItem Theme="{DynamicResource FluentDateTimePickerItem}">Standard Item</ListBoxItem>
<ListBoxItem Theme="{DynamicResource FluentDateTimePickerItem}" Classes="MonthItem">Month Item</ListBoxItem>
<RepeatButton Theme="{DynamicResource FluentDateTimePickerButton}">Button</RepeatButton>
<RepeatButton Theme="{DynamicResource FluentDateTimePickerUpButton}" IsVisible="True"/>
<RepeatButton Theme="{DynamicResource FluentDateTimePickerDownButton}" IsVisible="True"/>
</StackPanel>
</Border>
</Design.PreviewWith>
<!-- Theme for the items displayed in the selectors -->
<ControlTheme x:Key="FluentDateTimePickerItem" TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<Setter Property="Padding" Value="{DynamicResource DatePickerFlyoutPresenterItemPadding}"/>
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Style Selector="^:selected">
<Setter Property="IsHitTestVisible" Value="False"/>
<Style Selector="^/template/ Rectangle#PressedBackground">
<Setter Property="Fill" Value="Transparent"/>
</Style>
<Style Selector="^/template/ ContentPresenter">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}"/>
</Style>
</Style>
<Style Selector="^.MonthItem">
<Setter Property="Padding" Value="{DynamicResource DatePickerFlyoutPresenterMonthPadding}"/>
<Setter Property="HorizontalContentAlignment" Value="Left" />
</Style>
</ControlTheme>
<!-- This is used for both the accept/dismiss & repeatbuttons in the presenter-->
<ControlTheme x:Key="FluentDateTimePickerButton" TargetType="Button">
<Setter Property="Background" Value="{DynamicResource DateTimePickerFlyoutButtonBackground}" />
<Setter Property="Height" Value="22" />
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<ControlTemplate>
<!--
The background is doubled here for the loopingselector up/down repeat buttons
that appear opaque. Not sure how MS does it though I suspect this is it
but source isn't MIT yet, so this is my solution -->
<Border Background="{TemplateBinding Background}">
<ContentPresenter x:Name="ContentPresenter"
Background="{TemplateBinding Background}"
BorderBrush="{DynamicResource DateTimePickerFlyoutButtonBorderBrush}"
BorderThickness="{DynamicResource DateTimeFlyoutButtonBorderThickness}"
Content="{TemplateBinding Content}"
Foreground="{DynamicResource SystemControlHighlightAltBaseHighBrush}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
CornerRadius="{TemplateBinding CornerRadius}"/>
</Border>
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource DateTimePickerFlyoutButtonBackgroundPointerOver}"/>
<Setter Property="BorderBrush" Value="{DynamicResource DateTimePickerFlyoutButtonBorderBrushPointerOver}"/>
<Setter Property="Foreground" Value="{DynamicResource DateTimePickerFlyoutButtonForegroundPointerOver}"/>
</Style>
<Style Selector="^:pressed /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource DateTimePickerFlyoutButtonBackgroundPressed}"/>
<Setter Property="BorderBrush" Value="{DynamicResource DateTimePickerFlyoutButtonBorderBrushPressed}"/>
<Setter Property="Foreground" Value="{DynamicResource DateTimePickerFlyoutButtonForegroundPressed}"/>
</Style>
</ControlTheme>
<ControlTheme x:Key="FluentDateTimePickerUpButton" TargetType="RepeatButton" BasedOn="{StaticResource FluentDateTimePickerButton}">
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="Height" Value="22" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Focusable" Value="False" />
<Setter Property="Background" Value="{DynamicResource SystemControlBackgroundChromeMediumLowBrush}" />
<Setter Property="IsVisible" Value="False"/>
<Setter Property="Content">
<Template>
<Viewbox Height="10" Width="10" HorizontalAlignment="Center" VerticalAlignment="Center">
<Path Stroke="{Binding $parent[RepeatButton].Foreground}" StrokeThickness="1" Data="M 0,9 L 9,0 L 18,9"/>
</Viewbox>
</Template>
</Setter>
</ControlTheme>
<ControlTheme x:Key="FluentDateTimePickerDownButton" TargetType="RepeatButton" BasedOn="{StaticResource FluentDateTimePickerButton}">
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Height" Value="22" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Focusable" Value="False" />
<Setter Property="Background" Value="{DynamicResource SystemControlBackgroundChromeMediumLowBrush}" />
<Setter Property="IsVisible" Value="False"/>
<Setter Property="Content">
<Template>
<Viewbox Height="10" Width="10" HorizontalAlignment="Center" VerticalAlignment="Center">
<Path Stroke="{Binding $parent[RepeatButton].Foreground}" StrokeThickness="1" Data="M 0,0 L 9,9 L 18,0"/>
</Viewbox>
</Template>
</Setter>
</ControlTheme>
</ResourceDictionary>

192
src/Avalonia.Themes.Fluent/Controls/DropDownButton.xaml

@ -1,103 +1,97 @@
<Styles xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:CompileBindings="True"> x:CompileBindings="True">
<Design.PreviewWith>
<Design.PreviewWith> <Border Padding="20">
<Border Padding="20"> <StackPanel Spacing="20">
<StackPanel Spacing="20"> <DropDownButton Content="Click Me!" />
<DropDownButton Content="Click Me!" /> <DropDownButton Content="Disabled" IsEnabled="False" />
<DropDownButton Content="Disabled" IsEnabled="False" /> </StackPanel>
</StackPanel> </Border>
</Border> </Design.PreviewWith>
</Design.PreviewWith>
<Styles.Resources>
<x:Double x:Key="DropDownButtonMinHeight">32</x:Double>
</Styles.Resources>
<Style Selector="DropDownButton"> <x:Double x:Key="DropDownButtonMinHeight">32</x:Double>
<Setter Property="Background" Value="{DynamicResource ButtonBackground}" />
<Setter Property="Foreground" Value="{DynamicResource ButtonForeground}" /> <ControlTheme x:Key="{x:Type DropDownButton}" TargetType="DropDownButton">
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrush}" /> <Setter Property="Background" Value="{DynamicResource ButtonBackground}" />
<Setter Property="BorderThickness" Value="{DynamicResource ButtonBorderThemeThickness}" /> <Setter Property="Foreground" Value="{DynamicResource ButtonForeground}" />
<Setter Property="Padding" Value="{DynamicResource ButtonPadding}" /> <Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrush}" />
<Setter Property="MinHeight" Value="{DynamicResource DropDownButtonMinHeight}" /> <Setter Property="BorderThickness" Value="{DynamicResource ButtonBorderThemeThickness}" />
<Setter Property="HorizontalAlignment" Value="Left" /> <Setter Property="Padding" Value="{DynamicResource ButtonPadding}" />
<Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="MinHeight" Value="{DynamicResource DropDownButtonMinHeight}" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> <Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="VerticalAlignment" Value="Center" />
<!--<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}" /> <Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="FocusVisualMargin" Value="-3" />--> <Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" /> <Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate> <ControlTemplate>
<Border x:Name="RootBorder" <Border x:Name="RootBorder"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}" CornerRadius="{TemplateBinding CornerRadius}"
ClipToBounds="True"> ClipToBounds="True">
<Grid x:Name="InnerGrid"> <Grid x:Name="InnerGrid">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<ContentPresenter x:Name="PART_ContentPresenter" <ContentPresenter x:Name="PART_ContentPresenter"
Grid.Column="0" Grid.Column="0"
Content="{TemplateBinding Content}" Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplate="{TemplateBinding ContentTemplate}"
Padding="{TemplateBinding Padding}" Padding="{TemplateBinding Padding}"
RecognizesAccessKey="True" RecognizesAccessKey="True"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" /> VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
<PathIcon x:Name="DropDownGlyph" <PathIcon x:Name="DropDownGlyph"
Grid.Column="1" Grid.Column="1"
UseLayoutRounding="False" UseLayoutRounding="False"
IsHitTestVisible="False" IsHitTestVisible="False"
Height="12" Height="12"
Width="12" Width="12"
Margin="0,0,10,0" Margin="0,0,10,0"
HorizontalAlignment="Right" Data="M1939 486L2029 576L1024 1581L19 576L109 486L1024 1401L1939 486Z"
VerticalAlignment="Center" /> HorizontalAlignment="Right"
VerticalAlignment="Center"
</Grid> Foreground="{DynamicResource ComboBoxDropDownGlyphForeground}"/>
</Border> </Grid>
</ControlTemplate> </Border>
</Setter.Value> </ControlTemplate>
</Setter> </Setter.Value>
</Style> </Setter>
<!-- Normal State --> <!-- PointerOver State -->
<Style Selector="DropDownButton /template/ PathIcon#DropDownGlyph"> <Style Selector="^:pointerover /template/ Border#RootBorder">
<Setter Property="Foreground" Value="{DynamicResource ComboBoxDropDownGlyphForeground}" /> <Setter Property="Background" Value="{DynamicResource ButtonBackgroundPointerOver}" />
<Setter Property="Data" Value="M1939 486L2029 576L1024 1581L19 576L109 486L1024 1401L1939 486Z" /> <Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushPointerOver}" />
</Style> <Setter Property="TextElement.Foreground" Value="{DynamicResource ButtonForegroundPointerOver}" />
</Style>
<!-- PointerOver State -->
<Style Selector="DropDownButton:pointerover /template/ Border#RootBorder">
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundPointerOver}" />
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushPointerOver}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource ButtonForegroundPointerOver}" />
</Style>
<!-- Pressed State --> <!-- Pressed State -->
<Style Selector="DropDownButton:pressed /template/ Border#RootBorder"> <Style Selector="^:pressed">
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundPressed}" /> <Setter Property="RenderTransform" Value="scale(0.98)" />
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushPressed}" /> </Style>
<Setter Property="TextElement.Foreground" Value="{DynamicResource ButtonForegroundPressed}" />
</Style>
<!-- Disabled State --> <Style Selector="^:pressed /template/ Border#RootBorder">
<Style Selector="DropDownButton:disabled /template/ Border#RootBorder"> <Setter Property="Background" Value="{DynamicResource ButtonBackgroundPressed}" />
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundDisabled}" /> <Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushPressed}" />
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushDisabled}" /> <Setter Property="TextElement.Foreground" Value="{DynamicResource ButtonForegroundPressed}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource ButtonForegroundDisabled}" /> </Style>
</Style>
<Style Selector="DropDownButton:disabled /template/ PathIcon#DropDownGlyph">
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundDisabled}" />
</Style>
</Styles> <!-- Disabled State -->
<Style Selector="^:disabled /template/ Border#RootBorder">
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundDisabled}" />
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushDisabled}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource ButtonForegroundDisabled}" />
</Style>
<Style Selector="^:disabled /template/ PathIcon#DropDownGlyph">
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundDisabled}" />
</Style>
</ControlTheme>
</ResourceDictionary>

41
src/Avalonia.Themes.Fluent/Controls/EmbeddableControlRoot.xaml

@ -1,19 +1,22 @@
<Style xmlns="https://github.com/avaloniaui" Selector="EmbeddableControlRoot"> <ResourceDictionary xmlns="https://github.com/avaloniaui"
<Setter Property="Background" Value="{DynamicResource SystemControlBackgroundAltHighBrush}"/> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}"/> <ControlTheme x:Key="{x:Type EmbeddableControlRoot}" TargetType="EmbeddableControlRoot">
<Setter Property="Template"> <Setter Property="Background" Value="{DynamicResource SystemControlBackgroundAltHighBrush}"/>
<ControlTemplate> <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}"/>
<Panel> <Setter Property="Template">
<Border Name="PART_TransparencyFallback" IsHitTestVisible="False" /> <ControlTemplate>
<Border Background="{TemplateBinding Background}"> <Panel>
<VisualLayerManager> <Border Name="PART_TransparencyFallback" IsHitTestVisible="False" />
<ContentPresenter Name="PART_ContentPresenter" <Border Background="{TemplateBinding Background}">
ContentTemplate="{TemplateBinding ContentTemplate}" <VisualLayerManager>
Content="{TemplateBinding Content}" <ContentPresenter Name="PART_ContentPresenter"
Margin="{TemplateBinding Padding}"/> ContentTemplate="{TemplateBinding ContentTemplate}"
</VisualLayerManager> Content="{TemplateBinding Content}"
</Border> Margin="{TemplateBinding Padding}"/>
</Panel> </VisualLayerManager>
</ControlTemplate> </Border>
</Setter> </Panel>
</Style> </ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>

371
src/Avalonia.Themes.Fluent/Controls/Expander.xaml

@ -1,31 +1,41 @@
<Styles xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:CompileBindings="True"> x:CompileBindings="True">
<Design.PreviewWith> <Design.PreviewWith>
<Border Padding="20"> <Border Padding="20">
<StackPanel Orientation="Vertical" Spacing="20" Width="350"> <StackPanel Orientation="Vertical" Spacing="20" Width="350" Height="600">
<Expander ExpandDirection="Up" Header="Expand Up" CornerRadius="25"> <Expander ExpandDirection="Up" Header="Expand Up">
<Expander.Header> <StackPanel>
<Grid ColumnDefinitions="*, Auto"> <TextBlock>Expanded content</TextBlock>
<TextBlock Grid.Column="0" Text="Expand" /> </StackPanel>
<TextBlock Grid.Column="1" Text="Up" /> </Expander>
</Grid> <Expander ExpandDirection="Down" Header="Expand Down">
</Expander.Header> <StackPanel>
<TextBlock>Expanded content</TextBlock>
</StackPanel>
</Expander>
<Expander ExpandDirection="Left" Header="Expand Left">
<StackPanel> <StackPanel>
<TextBlock>Expanded content</TextBlock> <TextBlock>Expanded content</TextBlock>
</StackPanel> </StackPanel>
</Expander> </Expander>
<Expander ExpandDirection="Down" Header="Expand Down" CornerRadius="25"> <Expander ExpandDirection="Right" Header="Expand Right">
<StackPanel> <StackPanel>
<TextBlock>Expanded content</TextBlock> <TextBlock>Expanded content</TextBlock>
</StackPanel> </StackPanel>
</Expander> </Expander>
<Expander ExpandDirection="Left" Header="Expand Left" CornerRadius="25"> <Expander ExpandDirection="Up">
<Expander.Header>
<Grid ColumnDefinitions="*, Auto">
<TextBlock Grid.Column="0" Text="Control" />
<TextBlock Grid.Column="1" Text="Header" />
</Grid>
</Expander.Header>
<StackPanel> <StackPanel>
<TextBlock>Expanded content</TextBlock> <TextBlock>Expanded content</TextBlock>
</StackPanel> </StackPanel>
</Expander> </Expander>
<Expander ExpandDirection="Right" Header="Expand Right" CornerRadius="25"> <Expander ExpandDirection="Up" Header="Rounded" CornerRadius="25">
<StackPanel> <StackPanel>
<TextBlock>Expanded content</TextBlock> <TextBlock>Expanded content</TextBlock>
</StackPanel> </StackPanel>
@ -34,72 +44,28 @@
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Styles.Resources> <Thickness x:Key="ExpanderHeaderPadding">16</Thickness>
<Thickness x:Key="ExpanderHeaderPadding">16</Thickness> <Thickness x:Key="ExpanderContentPadding">16</Thickness>
<Thickness x:Key="ExpanderContentPadding">16</Thickness> <Thickness x:Key="ExpanderBorderThickness">1</Thickness>
<Thickness x:Key="ExpanderDropdownLeftBorderThickness">1,1,0,1</Thickness>
<Thickness x:Key="ExpanderBorderThickness">1</Thickness> <Thickness x:Key="ExpanderDropdownUpBorderThickness">1,1,1,0</Thickness>
<Thickness x:Key="ExpanderDropdownRightBorderThickness">0,1,1,1</Thickness>
<Thickness x:Key="ExpanderDropdownLeftBorderThickness">1,1,0,1</Thickness> <Thickness x:Key="ExpanderDropdownDownBorderThickness">1,0,1,1</Thickness>
<Thickness x:Key="ExpanderDropdownUpBorderThickness">1,1,1,0</Thickness> <SolidColorBrush x:Key="ExpanderBackground" Color="{DynamicResource SystemAltMediumHighColor}" />
<Thickness x:Key="ExpanderDropdownRightBorderThickness">0,1,1,1</Thickness> <SolidColorBrush x:Key="ExpanderBorderBrush" Color="{DynamicResource SystemBaseLowColor}" />
<Thickness x:Key="ExpanderDropdownDownBorderThickness">1,0,1,1</Thickness> <SolidColorBrush x:Key="ExpanderDropDownBackground" Color="{DynamicResource SystemChromeMediumLowColor}" />
<SolidColorBrush x:Key="ExpanderDropDownBorderBrush" Color="{DynamicResource SystemBaseLowColor}" />
<SolidColorBrush x:Key="ExpanderBackground" Color="{DynamicResource SystemAltMediumHighColor}" /> <SolidColorBrush x:Key="ExpanderForeground" Color="{DynamicResource SystemBaseHighColor}" />
<SolidColorBrush x:Key="ExpanderBorderBrush" Color="{DynamicResource SystemBaseLowColor}" /> <SolidColorBrush x:Key="ExpanderChevronForeground" Color="{DynamicResource SystemBaseHighColor}" />
<SolidColorBrush x:Key="ExpanderDropDownBackground" Color="{DynamicResource SystemChromeMediumLowColor}" />
<SolidColorBrush x:Key="ExpanderDropDownBorderBrush" Color="{DynamicResource SystemBaseLowColor}" />
<SolidColorBrush x:Key="ExpanderForeground" Color="{DynamicResource SystemBaseHighColor}" />
<SolidColorBrush x:Key="ExpanderChevronForeground" Color="{DynamicResource SystemBaseHighColor}" />
</Styles.Resources>
<Style Selector="Expander">
<Setter Property="Background" Value="{DynamicResource ExpanderBackground}" />
<Setter Property="BorderThickness" Value="{DynamicResource ExpanderBorderThickness}" />
<Setter Property="BorderBrush" Value="{DynamicResource ExpanderBorderBrush}" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="Padding" Value="{DynamicResource ExpanderHeaderPadding}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>
<Style Selector="Expander">
<Setter Property="Template">
<ControlTemplate>
<DockPanel>
<ToggleButton x:Name="ExpanderHeader"
Padding="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
IsChecked="{TemplateBinding IsExpanded, Mode=TwoWay}"
IsEnabled="{TemplateBinding IsEnabled}" />
<Border x:Name="ExpanderContent"
Padding="{DynamicResource ExpanderContentPadding}"
Background="{DynamicResource ExpanderDropDownBackground}"
BorderBrush="{DynamicResource ExpanderDropDownBorderBrush}"
IsVisible="{TemplateBinding IsExpanded, Mode=TwoWay}">
<ContentPresenter x:Name="PART_ContentPresenter"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}" />
</Border>
</DockPanel>
</ControlTemplate>
</Setter>
</Style>
<Style Selector="Expander /template/ ToggleButton#ExpanderHeader"> <ControlTheme x:Key="FluentExpanderToggleButtonTheme" TargetType="ToggleButton">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Border x:Name="ToggleButtonBackground"> <Border x:Name="ToggleButtonBackground"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
CornerRadius="{TemplateBinding CornerRadius}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid ColumnDefinitions="*,Auto"> <Grid ColumnDefinitions="*,Auto">
<ContentPresenter x:Name="PART_ContentPresenter" <ContentPresenter x:Name="PART_ContentPresenter"
Margin="{TemplateBinding Padding}" Margin="{TemplateBinding Padding}"
@ -132,110 +98,159 @@
</Border> </Border>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> <Style Selector="^:checked /template/ Border#ExpandCollapseChevronBorder">
<Style Selector="Expander /template/ ToggleButton#ExpanderHeader:pressed"> <Style.Animations>
<Setter Property="RenderTransform" Value="{x:Null}" /> <Animation FillMode="Both" Duration="0:0:0.0625">
</Style> <KeyFrame Cue="100%">
<Setter Property="RotateTransform.Angle" Value="180" />
<Style Selector="Expander:left /template/ ToggleButton#ExpanderHeader, Expander:right /template/ ToggleButton#ExpanderHeader"> </KeyFrame>
<Setter Property="VerticalAlignment" Value="Stretch" /> </Animation>
</Style> </Style.Animations>
</Style>
<Style Selector="^:not(:checked) /template/ Border#ExpandCollapseChevronBorder">
<Style Selector="Expander /template/ ToggleButton#ExpanderHeader /template/ Border#ToggleButtonBackground"> <Style.Animations>
<Setter Property="Background" Value="{TemplateBinding Background}" /> <Animation FillMode="Both" Duration="0:0:0.0625">
<Setter Property="BorderBrush" Value="{TemplateBinding BorderBrush}" /> <KeyFrame Cue="0%">
<Setter Property="BorderThickness" Value="{TemplateBinding BorderThickness}" /> <Setter Property="RotateTransform.Angle" Value="180" />
</Style> </KeyFrame>
<KeyFrame Cue="100%">
<Style Selector="Expander:not(:expanded) /template/ ToggleButton#ExpanderHeader /template/ Border#ToggleButtonBackground"> <Setter Property="RotateTransform.Angle" Value="0" />
<Setter Property="CornerRadius" Value="{Binding $parent[Expander].CornerRadius}" /> </KeyFrame>
</Style> </Animation>
<Style Selector="Expander:expanded:up /template/ ToggleButton#ExpanderHeader /template/ Border#ToggleButtonBackground"> </Style.Animations>
<Setter Property="CornerRadius" Value="{Binding $parent[Expander].CornerRadius, Converter={StaticResource BottomCornerRadiusFilterConverter}}" /> </Style>
</Style> </ControlTheme>
<Style Selector="Expander:expanded:up /template/ Border#ExpanderContent"> <ControlTheme x:Key="FluentExpanderToggleButtonUpTheme" TargetType="ToggleButton" BasedOn="{StaticResource FluentExpanderToggleButtonTheme}">
<Setter Property="CornerRadius" Value="{Binding $parent[Expander].CornerRadius, Converter={StaticResource TopCornerRadiusFilterConverter}}" /> <Style Selector="^ /template/ Path#ExpandCollapseChevron">
</Style> <Setter Property="Data" Value="M 0 7 L 7 0 L 14 7" />
<Style Selector="Expander:expanded:down /template/ ToggleButton#ExpanderHeader /template/ Border#ToggleButtonBackground"> </Style>
<Setter Property="CornerRadius" Value="{Binding $parent[Expander].CornerRadius, Converter={StaticResource TopCornerRadiusFilterConverter}}" /> </ControlTheme>
</Style> <ControlTheme x:Key="FluentExpanderToggleButtonDownTheme" TargetType="ToggleButton" BasedOn="{StaticResource FluentExpanderToggleButtonTheme}">
<Style Selector="Expander:expanded:down /template/ Border#ExpanderContent"> <Style Selector="^ /template/ Path#ExpandCollapseChevron">
<Setter Property="CornerRadius" Value="{Binding $parent[Expander].CornerRadius, Converter={StaticResource BottomCornerRadiusFilterConverter}}" /> <Setter Property="Data" Value="M 0 0 L 7 7 L 14 0" />
</Style> </Style>
<Style Selector="Expander:expanded:left /template/ ToggleButton#ExpanderHeader /template/ Border#ToggleButtonBackground"> </ControlTheme>
<Setter Property="CornerRadius" Value="{Binding $parent[Expander].CornerRadius, Converter={StaticResource RightCornerRadiusFilterConverter}}" /> <ControlTheme x:Key="FluentExpanderToggleButtonLeftTheme" TargetType="ToggleButton" BasedOn="{StaticResource FluentExpanderToggleButtonTheme}">
</Style> <Style Selector="^ /template/ Path#ExpandCollapseChevron">
<Style Selector="Expander:expanded:left /template/ Border#ExpanderContent"> <Setter Property="Data" Value="M 7 0 L 0 7 L 7 14" />
<Setter Property="CornerRadius" Value="{Binding $parent[Expander].CornerRadius, Converter={StaticResource LeftCornerRadiusFilterConverter}}" /> </Style>
</Style> </ControlTheme>
<Style Selector="Expander:expanded:right /template/ ToggleButton#ExpanderHeader /template/ Border#ToggleButtonBackground"> <ControlTheme x:Key="FluentExpanderToggleButtonRightTheme" TargetType="ToggleButton" BasedOn="{StaticResource FluentExpanderToggleButtonTheme}">
<Setter Property="CornerRadius" Value="{Binding $parent[Expander].CornerRadius, Converter={StaticResource LeftCornerRadiusFilterConverter}}" /> <Style Selector="^ /template/ Path#ExpandCollapseChevron">
</Style> <Setter Property="Data" Value="M 0 0 L 7 7 L 0 14" />
<Style Selector="Expander:expanded:right /template/ Border#ExpanderContent"> </Style>
<Setter Property="CornerRadius" Value="{Binding $parent[Expander].CornerRadius, Converter={StaticResource RightCornerRadiusFilterConverter}}" /> </ControlTheme>
</Style> <ControlTheme x:Key="{x:Type Expander}" TargetType="Expander">
<Setter Property="Background" Value="{DynamicResource ExpanderBackground}" />
<Setter Property="BorderThickness" Value="{DynamicResource ExpanderBorderThickness}" />
<Setter Property="BorderBrush" Value="{DynamicResource ExpanderBorderBrush}" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="Padding" Value="{DynamicResource ExpanderHeaderPadding}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<ControlTemplate>
<DockPanel>
<ToggleButton x:Name="ExpanderHeader"
Padding="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
HorizontalContentAlignment="Stretch"
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
IsChecked="{TemplateBinding IsExpanded, Mode=TwoWay}"
IsEnabled="{TemplateBinding IsEnabled}"/>
<Border x:Name="ExpanderContent"
Padding="{DynamicResource ExpanderContentPadding}"
Background="{DynamicResource ExpanderDropDownBackground}"
BorderBrush="{DynamicResource ExpanderDropDownBorderBrush}"
IsVisible="{TemplateBinding IsExpanded, Mode=TwoWay}">
<ContentPresenter x:Name="PART_ContentPresenter"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}" />
</Border>
</DockPanel>
</ControlTemplate>
</Setter>
<Style Selector="Expander:left /template/ ToggleButton#ExpanderHeader"> <Style Selector="^ /template/ ToggleButton#ExpanderHeader:pressed">
<Setter Property="DockPanel.Dock" Value="Right" /> <Setter Property="RenderTransform" Value="{x:Null}" />
</Style> </Style>
<Style Selector="Expander:up /template/ ToggleButton#ExpanderHeader">
<Setter Property="DockPanel.Dock" Value="Bottom" />
</Style>
<Style Selector="Expander:right /template/ ToggleButton#ExpanderHeader">
<Setter Property="DockPanel.Dock" Value="Left" />
</Style>
<Style Selector="Expander:down /template/ ToggleButton#ExpanderHeader">
<Setter Property="DockPanel.Dock" Value="Top" />
</Style>
<Style Selector="^:left /template/ ToggleButton#ExpanderHeader, ^:right /template/ ToggleButton#ExpanderHeader">
<Setter Property="VerticalAlignment" Value="Stretch" />
</Style>
<Style Selector="Expander:expanded /template/ ToggleButton#ExpanderHeader /template/ Border#ExpandCollapseChevronBorder"> <Style Selector="^:not(:expanded) /template/ ToggleButton#ExpanderHeader">
<Style.Animations> <Setter Property="CornerRadius" Value="{Binding $parent[Expander].CornerRadius}" />
<Animation FillMode="Both" Duration="0:0:0.0625"> </Style>
<KeyFrame Cue="100%"> <Style Selector="^:expanded:up /template/ ToggleButton#ExpanderHeader">
<Setter Property="RotateTransform.Angle" Value="180" /> <Setter Property="CornerRadius" Value="{TemplateBinding CornerRadius, Converter={StaticResource BottomCornerRadiusFilterConverter}}" />
</KeyFrame> </Style>
</Animation> <Style Selector="^:expanded:up /template/ Border#ExpanderContent">
</Style.Animations> <Setter Property="CornerRadius" Value="{TemplateBinding CornerRadius, Converter={StaticResource TopCornerRadiusFilterConverter}}" />
</Style> </Style>
<Style Selector="Expander:not(:expanded) /template/ ToggleButton#ExpanderHeader /template/ Border#ExpandCollapseChevronBorder"> <Style Selector="^:expanded:down /template/ ToggleButton#ExpanderHeader">
<Style.Animations> <Setter Property="CornerRadius" Value="{TemplateBinding CornerRadius, Converter={StaticResource TopCornerRadiusFilterConverter}}" />
<Animation FillMode="Both" Duration="0:0:0.0625"> </Style>
<KeyFrame Cue="0%"> <Style Selector="^:expanded:down /template/ Border#ExpanderContent">
<Setter Property="RotateTransform.Angle" Value="180" /> <Setter Property="CornerRadius" Value="{TemplateBinding CornerRadius, Converter={StaticResource BottomCornerRadiusFilterConverter}}" />
</KeyFrame> </Style>
<KeyFrame Cue="100%"> <Style Selector="^:expanded:left /template/ ToggleButton#ExpanderHeader">
<Setter Property="RotateTransform.Angle" Value="0" /> <Setter Property="CornerRadius" Value="{TemplateBinding CornerRadius, Converter={StaticResource RightCornerRadiusFilterConverter}}" />
</KeyFrame> </Style>
</Animation> <Style Selector="^:expanded:left /template/ Border#ExpanderContent">
</Style.Animations> <Setter Property="CornerRadius" Value="{TemplateBinding CornerRadius, Converter={StaticResource LeftCornerRadiusFilterConverter}}" />
</Style> </Style>
<Style Selector="^:expanded:right /template/ ToggleButton#ExpanderHeader">
<Setter Property="CornerRadius" Value="{TemplateBinding CornerRadius, Converter={StaticResource LeftCornerRadiusFilterConverter}}" />
</Style>
<Style Selector="^:expanded:right /template/ Border#ExpanderContent">
<Setter Property="CornerRadius" Value="{TemplateBinding CornerRadius, Converter={StaticResource RightCornerRadiusFilterConverter}}" />
</Style>
<Style Selector="Expander:left /template/ ToggleButton#ExpanderHeader /template/ Path#ExpandCollapseChevron"> <Style Selector="^:left /template/ ToggleButton#ExpanderHeader">
<Setter Property="Data" Value="M 7 0 L 0 7 L 7 14" /> <Setter Property="DockPanel.Dock" Value="Right" />
</Style> </Style>
<Style Selector="Expander:up /template/ ToggleButton#ExpanderHeader /template/ Path#ExpandCollapseChevron"> <Style Selector="^:up /template/ ToggleButton#ExpanderHeader">
<Setter Property="Data" Value="M 0 7 L 7 0 L 14 7" /> <Setter Property="DockPanel.Dock" Value="Bottom" />
</Style> </Style>
<Style Selector="Expander:right /template/ ToggleButton#ExpanderHeader /template/ Path#ExpandCollapseChevron"> <Style Selector="^:right /template/ ToggleButton#ExpanderHeader">
<Setter Property="Data" Value="M 0 0 L 7 7 L 0 14" /> <Setter Property="DockPanel.Dock" Value="Left" />
</Style> </Style>
<Style Selector="Expander:down /template/ ToggleButton#ExpanderHeader /template/ Path#ExpandCollapseChevron"> <Style Selector="^:down /template/ ToggleButton#ExpanderHeader">
<Setter Property="Data" Value="M 0 0 L 7 7 L 14 0" /> <Setter Property="DockPanel.Dock" Value="Top" />
</Style> </Style>
<Style Selector="^:left /template/ ToggleButton#ExpanderHeader">
<Setter Property="Theme" Value="{StaticResource FluentExpanderToggleButtonLeftTheme}" />
</Style>
<Style Selector="^:up /template/ ToggleButton#ExpanderHeader">
<Setter Property="Theme" Value="{StaticResource FluentExpanderToggleButtonUpTheme}" />
</Style>
<Style Selector="^:right /template/ ToggleButton#ExpanderHeader">
<Setter Property="Theme" Value="{StaticResource FluentExpanderToggleButtonRightTheme}" />
</Style>
<Style Selector="^:down /template/ ToggleButton#ExpanderHeader">
<Setter Property="Theme" Value="{StaticResource FluentExpanderToggleButtonDownTheme}" />
</Style>
<Style Selector="Expander:left /template/ Border#ExpanderContent"> <Style Selector="^:left /template/ Border#ExpanderContent">
<Setter Property="BorderThickness" Value="{DynamicResource ExpanderDropdownLeftBorderThickness}" /> <Setter Property="BorderThickness" Value="{DynamicResource ExpanderDropdownLeftBorderThickness}" />
</Style> </Style>
<Style Selector="Expander:up /template/ Border#ExpanderContent"> <Style Selector="^:up /template/ Border#ExpanderContent">
<Setter Property="BorderThickness" Value="{DynamicResource ExpanderDropdownUpBorderThickness}" /> <Setter Property="BorderThickness" Value="{DynamicResource ExpanderDropdownUpBorderThickness}" />
</Style> </Style>
<Style Selector="Expander:right /template/ Border#ExpanderContent"> <Style Selector="^:right /template/ Border#ExpanderContent">
<Setter Property="BorderThickness" Value="{DynamicResource ExpanderDropdownRightBorderThickness}" /> <Setter Property="BorderThickness" Value="{DynamicResource ExpanderDropdownRightBorderThickness}" />
</Style> </Style>
<Style Selector="Expander:down /template/ Border#ExpanderContent"> <Style Selector="^:down /template/ Border#ExpanderContent">
<Setter Property="BorderThickness" Value="{DynamicResource ExpanderDropdownDownBorderThickness}" /> <Setter Property="BorderThickness" Value="{DynamicResource ExpanderDropdownDownBorderThickness}" />
</Style> </Style>
</Styles> </ControlTheme>
</ResourceDictionary>

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

@ -1,71 +1,78 @@
<Styles xmlns="https://github.com/avaloniaui" <Styles
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="Avalonia.Themes.Fluent.Controls.FluentControls"
x:Class="Avalonia.Themes.Fluent.Controls.FluentControls"> xmlns="https://github.com/avaloniaui"
<!-- Define ToolTip first so its styles can be overriden by other controls (e.g. TextBox) --> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ToolTip.xaml"/> <Styles.Resources>
<!-- PathIcon also needs to be defined early so it can be overriden by other styles (e.g. ComboBox) --> <ResourceDictionary>
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/PathIcon.xaml" /> <ResourceDictionary.MergedDictionaries>
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/DataValidationErrors.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/Button.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/FocusAdorner.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/RadioButton.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/Button.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/Expander.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/CaptionButtons.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/ProgressBar.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/Carousel.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/CheckBox.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/ButtonSpinner.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ComboBox.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/Calendar.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ComboBoxItem.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/CalendarButton.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ContentControl.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/CalendarDatePicker.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/DropDownButton.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/CalendarDayButton.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/Label.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/CalendarItem.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/GridSplitter.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/CaptionButtons.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ItemsControl.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/Carousel.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ListBox.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/CheckBox.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ListBoxItem.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/FlyoutPresenter.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/Menu.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/GridSplitter.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ContextMenu.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/ItemsControl.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/MenuItem.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/Label.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/OverlayPopupHost.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/ListBox.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/PopupRoot.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/ListBoxItem.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ProgressBar.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/MenuScrollViewer.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/RadioButton.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/Menu.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/RepeatButton.xaml" /> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/MenuItem.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/Separator.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/MenuFlyoutPresenter.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/Slider.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/NativeMenuBar.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ScrollBar.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/NotificationCard.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ScrollViewer.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/TabStrip.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/OverlayPopupHost.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/TabStripItem.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/PopupRoot.xaml" />
<!-- TabControl needs to come after TabStrip as it redefines the inner TabStrip.ItemsPanel--> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/PathIcon.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/TabControl.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/RepeatButton.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/TabItem.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/ScrollBar.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/TextBox.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/ScrollViewer.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ToggleButton.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/Separator.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/TransitioningContentControl.xaml" /> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/SplitButton.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/Expander.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/SplitView.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/TitleBar.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/TabControl.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/TreeView.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/TabItem.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/TreeViewItem.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/TabStrip.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/UserControl.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/TabStripItem.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/Window.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/TextBox.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/EmbeddableControlRoot.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/ToggleButton.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/CalendarButton.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/ToggleSwitch.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/CalendarDayButton.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/ToolTip.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/CalendarItem.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/TitleBar.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/Calendar.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/TransitioningContentControl.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/CalendarDatePicker.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/TreeView.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ButtonSpinner.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/TreeViewItem.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/WindowNotificationManager.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/Window.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/WindowNotificationManager.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/ComboBox.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/NotificationCard.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/ComboBoxItem.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/NativeMenuBar.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/ContentControl.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ToggleSwitch.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/ContextMenu.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/SplitButton.xaml" /> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/DataValidationErrors.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/SplitView.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/DateTimePickerShared.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/DatePicker.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/DatePicker.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/TimePicker.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/TimePicker.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/FlyoutPresenter.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/DropDownButton.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/MenuFlyoutPresenter.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/EmbeddableControlRoot.xaml" />
<!-- ManagedFileChooser comes last because it uses (and overrides) styles for a multitude of other controls...the dialogs were originally UserControls, after all--> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/Slider.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ManagedFileChooser.xaml"/> <!-- ManagedFileChooser comes last because it uses (and overrides) styles for a multitude of other controls...the dialogs were originally UserControls, after all -->
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/RichTextBlock.xaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Fluent/Controls/ManagedFileChooser.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Styles.Resources>
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/FocusAdorner.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/UserControl.xaml" />
<Styles.Resources />
</Styles> </Styles>

14
src/Avalonia.Themes.Fluent/Controls/FlyoutPresenter.xaml

@ -1,9 +1,7 @@
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ResourceDictionary xmlns="https://github.com/avaloniaui"
<Styles.Resources> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Thickness x:Key="FlyoutBorderThemeThickness">1</Thickness> <Thickness x:Key="FlyoutBorderThemeThickness">1</Thickness>
</Styles.Resources> <ControlTheme x:Key="{x:Type FlyoutPresenter}" TargetType="FlyoutPresenter">
<Style Selector="FlyoutPresenter">
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> <Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" /> <Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="Background" Value="{DynamicResource FlyoutPresenterBackground}" /> <Setter Property="Background" Value="{DynamicResource FlyoutPresenterBackground}" />
@ -38,5 +36,5 @@
</Border> </Border>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> </ControlTheme>
</Styles> </ResourceDictionary>

2
src/Avalonia.Themes.Fluent/Controls/FocusAdorner.xaml

@ -1,4 +1,4 @@
<Styles xmlns="https://github.com/avaloniaui" <Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Styles.Resources> <Styles.Resources>
<Thickness x:Key="SystemControlFocusVisualMargin">0</Thickness> <Thickness x:Key="SystemControlFocusVisualMargin">0</Thickness>

46
src/Avalonia.Themes.Fluent/Controls/GridSplitter.xaml

@ -1,24 +1,22 @@
<Styles xmlns="https://github.com/avaloniaui"> <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style Selector="GridSplitter"> <ControlTheme x:Key="{x:Type GridSplitter}" TargetType="GridSplitter">
<Setter Property="Focusable" Value="True" /> <Setter Property="Focusable" Value="True" />
<Setter Property="MinWidth" Value="6" /> <Setter Property="MinWidth" Value="6" />
<Setter Property="MinHeight" Value="6" /> <Setter Property="MinHeight" Value="6" />
<Setter Property="Background" Value="{DynamicResource SystemAltMediumLowColor}" /> <Setter Property="Background" Value="{DynamicResource SystemAltMediumLowColor}" />
<Setter Property="PreviewContent"> <Setter Property="PreviewContent">
<Template> <Template>
<Rectangle Fill="{DynamicResource SystemAccentColor}" /> <Rectangle Fill="{DynamicResource SystemAccentColor}" />
</Template> </Template>
</Setter> </Setter>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Border <Border BorderBrush="{TemplateBinding BorderBrush}"
BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}"
CornerRadius="{TemplateBinding CornerRadius}" Background="{TemplateBinding Background}" />
Background="{TemplateBinding Background}"/> </ControlTemplate>
</ControlTemplate> </Setter>
</Setter> </ControlTheme>
</Style> </ResourceDictionary>
</Styles>

35
src/Avalonia.Themes.Fluent/Controls/ItemsControl.xaml

@ -1,16 +1,19 @@
<Style xmlns="https://github.com/avaloniaui" Selector="ItemsControl"> <ResourceDictionary xmlns="https://github.com/avaloniaui"
<Setter Property="Template"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTemplate> <ControlTheme x:Key="{x:Type ItemsControl}" TargetType="ItemsControl">
<Border Background="{TemplateBinding Background}" <Setter Property="Template">
BorderBrush="{TemplateBinding BorderBrush}" <ControlTemplate>
BorderThickness="{TemplateBinding BorderThickness}" <Border Background="{TemplateBinding Background}"
CornerRadius="{TemplateBinding CornerRadius}" BorderBrush="{TemplateBinding BorderBrush}"
Padding="{TemplateBinding Padding}"> BorderThickness="{TemplateBinding BorderThickness}"
<ItemsPresenter Name="PART_ItemsPresenter" CornerRadius="{TemplateBinding CornerRadius}"
Items="{TemplateBinding Items}" Padding="{TemplateBinding Padding}">
ItemsPanel="{TemplateBinding ItemsPanel}" <ItemsPresenter Name="PART_ItemsPresenter"
ItemTemplate="{TemplateBinding ItemTemplate}"/> Items="{TemplateBinding Items}"
</Border> ItemsPanel="{TemplateBinding ItemsPanel}"
</ControlTemplate> ItemTemplate="{TemplateBinding ItemTemplate}"/>
</Setter> </Border>
</Style> </ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>

40
src/Avalonia.Themes.Fluent/Controls/Label.xaml

@ -1,18 +1,22 @@
<Style xmlns="https://github.com/avaloniaui" Selector="Label"> <ResourceDictionary xmlns="https://github.com/avaloniaui"
<Setter Property="Padding" Value="3"/> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Setter Property="Template">
<ControlTemplate> <ControlTheme x:Key="{x:Type Label}" TargetType="Label">
<ContentPresenter Name="PART_ContentPresenter" <Setter Property="Padding" Value="3"/>
Background="{TemplateBinding Background}" <Setter Property="Template">
BorderBrush="{TemplateBinding BorderBrush}" <ControlTemplate>
BorderThickness="{TemplateBinding BorderThickness}" <ContentPresenter Name="PART_ContentPresenter"
CornerRadius="{TemplateBinding CornerRadius}" Background="{TemplateBinding Background}"
ContentTemplate="{TemplateBinding ContentTemplate}" BorderBrush="{TemplateBinding BorderBrush}"
Content="{TemplateBinding Content}" BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}" CornerRadius="{TemplateBinding CornerRadius}"
RecognizesAccessKey="True" ContentTemplate="{TemplateBinding ContentTemplate}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"/> Padding="{TemplateBinding Padding}"
</ControlTemplate> RecognizesAccessKey="True"
</Setter> VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
</Style> HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"/>
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>

18
src/Avalonia.Themes.Fluent/Controls/ListBox.xaml

@ -1,4 +1,5 @@
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith> <Design.PreviewWith>
<Border Padding="20"> <Border Padding="20">
<ListBox> <ListBox>
@ -9,15 +10,16 @@
</ListBox> </ListBox>
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Style Selector="ListBox">
<ControlTheme x:Key="{x:Type ListBox}" TargetType="ListBox">
<Setter Property="Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}" /> <Setter Property="Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}" />
<Setter Property="Background" Value="{DynamicResource SystemControlBackgroundChromeMediumLowBrush}" /> <Setter Property="Background" Value="{DynamicResource SystemControlBackgroundChromeMediumLowBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource SystemControlForegroundBaseHighBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource SystemControlForegroundBaseHighBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource ListBoxBorderThemeThickness}" /> <Setter Property="BorderThickness" Value="{DynamicResource ListBoxBorderThemeThickness}" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" /> <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" /> <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.IsScrollChainingEnabled" Value="True" /> <Setter Property="ScrollViewer.IsScrollChainingEnabled" Value="True" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Border Name="border" <Border Name="border"
@ -36,10 +38,10 @@
ItemsPanel="{TemplateBinding ItemsPanel}" ItemsPanel="{TemplateBinding ItemsPanel}"
ItemTemplate="{TemplateBinding ItemTemplate}" ItemTemplate="{TemplateBinding ItemTemplate}"
Margin="{TemplateBinding Padding}" Margin="{TemplateBinding Padding}"
VirtualizationMode="{TemplateBinding VirtualizationMode}"/> VirtualizationMode="{TemplateBinding VirtualizationMode}" />
</ScrollViewer> </ScrollViewer>
</Border> </Border>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> </ControlTheme>
</Styles> </ResourceDictionary>

101
src/Avalonia.Themes.Fluent/Controls/ListBoxItem.xaml

@ -1,5 +1,5 @@
<Styles xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith> <Design.PreviewWith>
<Border Padding="0"> <Border Padding="0">
<ListBox> <ListBox>
@ -12,10 +12,8 @@
</ListBox> </ListBox>
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Styles.Resources> <Thickness x:Key="ListBoxItemPadding">12,9,12,12</Thickness>
<Thickness x:Key="ListBoxItemPadding">12,9,12,12</Thickness> <ControlTheme x:Key="{x:Type ListBoxItem}" TargetType="ListBoxItem">
</Styles.Resources>
<Style Selector="ListBoxItem">
<Setter Property="Background" Value="Transparent" /> <Setter Property="Background" Value="Transparent" />
<Setter Property="Padding" Value="{DynamicResource ListBoxItemPadding}" /> <Setter Property="Padding" Value="{DynamicResource ListBoxItemPadding}" />
<Setter Property="Template"> <Setter Property="Template">
@ -27,68 +25,55 @@
CornerRadius="{TemplateBinding CornerRadius}" CornerRadius="{TemplateBinding CornerRadius}"
ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}" Content="{TemplateBinding Content}"
FontWeight="Normal"
FontSize="{DynamicResource ControlContentThemeFontSize}"
Padding="{TemplateBinding Padding}" Padding="{TemplateBinding Padding}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" /> HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" />
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style>
<Style Selector="ListBoxItem /template/ ContentPresenter#PART_ContentPresenter"> <Style Selector="^:disabled /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="FontWeight" Value="Normal" /> <Setter Property="Foreground" Value="{DynamicResource SystemControlDisabledBaseMediumLowBrush}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> </Style>
</Style>
<!-- Disabled State --> <!-- PointerOver State -->
<Style Selector="ListBoxItem:disabled /template/ ContentPresenter#PART_ContentPresenter"> <Style Selector="^:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource SystemControlDisabledBaseMediumLowBrush}" /> <Setter Property="Background" Value="{DynamicResource SystemControlHighlightListLowBrush}" />
</Style> <Setter Property="Foreground" Value="{DynamicResource SystemControlHighlightAltBaseHighBrush}" />
</Style>
<!-- PointerOver State --> <!-- Pressed State -->
<Style Selector="ListBoxItem:pointerover /template/ ContentPresenter#PART_ContentPresenter"> <Style Selector="^:pressed /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource SystemControlHighlightListLowBrush}" /> <Setter Property="Background" Value="{DynamicResource SystemControlHighlightListMediumBrush}" />
</Style> <Setter Property="Foreground" Value="{DynamicResource SystemControlHighlightAltBaseHighBrush}" />
<Style Selector="ListBoxItem:pointerover /template/ ContentPresenter#PART_ContentPresenter"> </Style>
<Setter Property="Foreground" Value="{DynamicResource SystemControlHighlightAltBaseHighBrush}" />
</Style>
<!-- Pressed State --> <!-- Selected State -->
<Style Selector="ListBoxItem:pressed /template/ ContentPresenter#PART_ContentPresenter"> <Style Selector="^:selected">
<Setter Property="Background" Value="{DynamicResource SystemControlHighlightListMediumBrush}" />
</Style>
<Style Selector="ListBoxItem:pressed /template/ ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource SystemControlHighlightAltBaseHighBrush}" />
</Style>
<!-- Selected State --> <Style Selector="^ /template/ ContentPresenter#PART_ContentPresenter">
<Style Selector="ListBoxItem:selected /template/ ContentPresenter#PART_ContentPresenter"> <Setter Property="Background" Value="{DynamicResource SystemControlHighlightListAccentLowBrush}" />
<Setter Property="Background" Value="{DynamicResource SystemControlHighlightListAccentLowBrush}" /> <Setter Property="Foreground" Value="{DynamicResource SystemControlHighlightAltBaseHighBrush}" />
</Style> </Style>
<Style Selector="ListBoxItem:selected /template/ ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource SystemControlHighlightAltBaseHighBrush}" />
</Style>
<!-- Selected Unfocused State --> <!-- Selected Unfocused State -->
<Style Selector="ListBoxItem:selected:not(:focus) /template/ ContentPresenter#PART_ContentPresenter"> <Style Selector="^:not(:focus) /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource SystemControlHighlightListAccentLowBrush}" /> <Setter Property="Background" Value="{DynamicResource SystemControlHighlightListAccentLowBrush}" />
</Style> <Setter Property="Foreground" Value="{DynamicResource SystemControlHighlightAltBaseHighBrush}" />
<Style Selector="ListBoxItem:selected:not(:focus) /template/ ContentPresenter#PART_ContentPresenter"> </Style>
<Setter Property="Foreground" Value="{DynamicResource SystemControlHighlightAltBaseHighBrush}" />
</Style>
<!-- Selected PointerOver State --> <!-- Selected PointerOver State -->
<Style Selector="ListBoxItem:selected:pointerover /template/ ContentPresenter#PART_ContentPresenter"> <Style Selector="^:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource SystemControlHighlightListAccentMediumBrush}" /> <Setter Property="Background" Value="{DynamicResource SystemControlHighlightListAccentMediumBrush}" />
</Style> <Setter Property="Foreground" Value="{DynamicResource SystemControlHighlightAltBaseHighBrush}" />
<Style Selector="ListBoxItem:selected:pointerover /template/ ContentPresenter"> </Style>
<Setter Property="Foreground" Value="{DynamicResource SystemControlHighlightAltBaseHighBrush}" />
</Style>
<!-- Selected Pressed State --> <!-- Selected Pressed State -->
<Style Selector="ListBoxItem:selected:pressed /template/ ContentPresenter#PART_ContentPresenter"> <Style Selector="^:pressed /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource SystemControlHighlightListAccentHighBrush}" /> <Setter Property="Background" Value="{DynamicResource SystemControlHighlightListAccentHighBrush}" />
</Style> <Setter Property="Foreground" Value="{DynamicResource SystemControlHighlightAltBaseHighBrush}" />
<Style Selector="ListBoxItem:selected:pressed /template/ ContentPresenter#PART_ContentPresenter"> </Style>
<Setter Property="Foreground" Value="{DynamicResource SystemControlHighlightAltBaseHighBrush}" /> </Style>
</Style> </ControlTheme>
</Styles> </ResourceDictionary>

604
src/Avalonia.Themes.Fluent/Controls/ManagedFileChooser.xaml

@ -1,324 +1,328 @@
<Styles xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dialogs="clr-namespace:Avalonia.Dialogs;assembly=Avalonia.Dialogs"> xmlns:dialogs="clr-namespace:Avalonia.Dialogs;assembly=Avalonia.Dialogs">
<Style Selector="dialogs|ManagedFileChooser"> <Design.PreviewWith>
<Style.Resources> <Border Padding="20" Width="800" Height="500">
<ResourceDictionary> <dialogs:ManagedFileChooser/>
<GradientStops x:Key="IconRes.FolderBackGradientStops"> </Border>
</GradientStops> </Design.PreviewWith>
<GradientStops x:Key="IconRes.FolderFrontGradientStops">
<GradientStop Offset="0" Color="#FFFFDA6F"/> <ControlTheme x:Key="{x:Type dialogs:ManagedFileChooser}" TargetType="dialogs:ManagedFileChooser">
<GradientStop Offset="1" Color="#FFFEC326"/> <ControlTheme.Resources>
</GradientStops> <ResourceDictionary>
<DrawingGroup x:Key="LevelUp"> <GradientStops x:Key="IconRes.FolderBackGradientStops">
<GeometryDrawing Brush="#00FFFFFF" Geometry="F1M16,16L0,16 0,0 16,0z" /> </GradientStops>
<GeometryDrawing Brush="#FFF6F6F6" Geometry="F1M14.5,0L6.39,0 5.39,2 2.504,2C1.677,2,1,2.673,1,3.5L1,10.582 1,10.586 1,15.414 3,13.414 3,16 7,16 7,13.414 9,15.414 9,13 14.5,13C15.327,13,16,12.327,16,11.5L16,1.5C16,0.673,15.327,0,14.5,0" /> <GradientStops x:Key="IconRes.FolderFrontGradientStops">
<GeometryDrawing Brush="#FFDCB679" Geometry="F1M14,3L7.508,3 8.008,2 8.012,2 14,2z M14.5,1L7.008,1 6.008,3 2.504,3C2.227,3,2,3.224,2,3.5L2,9.582 4.998,6.586 9,10.586 9,12 14.5,12C14.775,12,15,11.776,15,11.5L15,1.5C15,1.224,14.775,1,14.5,1" /> <GradientStop Offset="0" Color="#FFFFDA6F"/>
<GeometryDrawing Brush="#FF00529C" Geometry="F1M8,11L5,8 2,11 2,13 4,11 4,15 6,15 6,11 8,13z" /> <GradientStop Offset="1" Color="#FFFEC326"/>
<GeometryDrawing Brush="#FFF0EFF1" Geometry="F1M8.0001,1.9996L7.5001,3.0006 14.0001,3.0006 14.0001,1.9996z" /> </GradientStops>
</DrawingGroup> <DrawingGroup x:Key="LevelUp">
<dialogs:ResourceSelectorConverter x:Key="Icons"> <GeometryDrawing Brush="#00FFFFFF" Geometry="F1M16,16L0,16 0,0 16,0z" />
<DrawingGroup x:Key="Icon_Folder"> <GeometryDrawing Brush="#FFF6F6F6" Geometry="F1M14.5,0L6.39,0 5.39,2 2.504,2C1.677,2,1,2.673,1,3.5L1,10.582 1,10.586 1,15.414 3,13.414 3,16 7,16 7,13.414 9,15.414 9,13 14.5,13C15.327,13,16,12.327,16,11.5L16,1.5C16,0.673,15.327,0,14.5,0" />
<GeometryDrawing Geometry="M 0 0 L 16 16"/> <GeometryDrawing Brush="#FFDCB679" Geometry="F1M14,3L7.508,3 8.008,2 8.012,2 14,2z M14.5,1L7.008,1 6.008,3 2.504,3C2.227,3,2,3.224,2,3.5L2,9.582 4.998,6.586 9,10.586 9,12 14.5,12C14.775,12,15,11.776,15,11.5L15,1.5C15,1.224,14.775,1,14.5,1" />
<GeometryDrawing Geometry="M 0 3 C 0,1 0,1 2,1 L 5 1 C 5.5,1 6,1 6.5,1.5 L 8 3 L 14 3 C 16,3 16,3 16,5 <GeometryDrawing Brush="#FF00529C" Geometry="F1M8,11L5,8 2,11 2,13 4,11 4,15 6,15 6,11 8,13z" />
<GeometryDrawing Brush="#FFF0EFF1" Geometry="F1M8.0001,1.9996L7.5001,3.0006 14.0001,3.0006 14.0001,1.9996z" />
</DrawingGroup>
<dialogs:ResourceSelectorConverter x:Key="Icons">
<DrawingGroup x:Key="Icon_Folder">
<GeometryDrawing Geometry="M 0 0 L 16 16"/>
<GeometryDrawing Geometry="M 0 3 C 0,1 0,1 2,1 L 5 1 C 5.5,1 6,1 6.5,1.5 L 8 3 L 14 3 C 16,3 16,3 16,5
L 16,12 C 16,14 16,14 14,14 L 16,12 C 16,14 16,14 14,14
L 2,14 C 0,14 0,14 0,12 Z"> L 2,14 C 0,14 0,14 0,12 Z">
<GeometryDrawing.Brush> <GeometryDrawing.Brush>
<LinearGradientBrush StartPoint="1,4" EndPoint="23,20"> <LinearGradientBrush StartPoint="1,4" EndPoint="23,20">
<GradientStop Offset="0" Color="#FFFFC018"/> <GradientStop Offset="0" Color="#FFFFC018"/>
<GradientStop Offset="1" Color="#FFDFA32D"/> <GradientStop Offset="1" Color="#FFDFA32D"/>
</LinearGradientBrush> </LinearGradientBrush>
</GeometryDrawing.Brush> </GeometryDrawing.Brush>
</GeometryDrawing> </GeometryDrawing>
<GeometryDrawing Geometry="M 0 4.5 L 8 4.5 L 8 9 L 0 9 Z"> <GeometryDrawing Geometry="M 0 4.5 L 8 4.5 L 8 9 L 0 9 Z">
<GeometryDrawing.Brush> <GeometryDrawing.Brush>
<LinearGradientBrush StartPoint="0,4.5" EndPoint="0,5"> <LinearGradientBrush StartPoint="0,4.5" EndPoint="0,5">
<GradientStop Offset="0" Color="#00D7A018"/> <GradientStop Offset="0" Color="#00D7A018"/>
<GradientStop Offset="1" Color="#7FD7A018"/> <GradientStop Offset="1" Color="#7FD7A018"/>
</LinearGradientBrush> </LinearGradientBrush>
</GeometryDrawing.Brush> </GeometryDrawing.Brush>
</GeometryDrawing> </GeometryDrawing>
<GeometryDrawing Geometry="M 0 9 C 0,5 0,5 2,5 L 5 5 C 5.5,5 6,5 6.5,4.75 L 8 4 L 14 4 C 16,4 16,4 16,6 <GeometryDrawing Geometry="M 0 9 C 0,5 0,5 2,5 L 5 5 C 5.5,5 6,5 6.5,4.75 L 8 4 L 14 4 C 16,4 16,4 16,6
L 16,11 C 16,13 16,13 14,13 L 16,11 C 16,13 16,13 14,13
L 2,13 C 0,13 0,13 0,11 Z"> L 2,13 C 0,13 0,13 0,11 Z">
<GeometryDrawing.Brush> <GeometryDrawing.Brush>
<LinearGradientBrush StartPoint="1,6" EndPoint="23,19"> <LinearGradientBrush StartPoint="1,6" EndPoint="23,19">
<GradientStop Offset="0" Color="#FFFFE69D"/> <GradientStop Offset="0" Color="#FFFFE69D"/>
<GradientStop Offset="1" Color="#FFFFC937"/> <GradientStop Offset="1" Color="#FFFFC937"/>
</LinearGradientBrush> </LinearGradientBrush>
</GeometryDrawing.Brush> </GeometryDrawing.Brush>
</GeometryDrawing> </GeometryDrawing>
<GeometryDrawing Geometry="M 0 9 C 0,5 0,5 2,5 L 5 5 C 5.5,5 6,5 6.5,4.75 L 8 4 L 14 4 <GeometryDrawing Geometry="M 0 9 C 0,5 0,5 2,5 L 5 5 C 5.5,5 6,5 6.5,4.75 L 8 4 L 14 4
L 8 4.25 C 6,5.25 5.5,5.25 5.125,5.25 L 2 5.25 C 0,5.25 0,5.25 0,9.25 z" Brush="#7FFFFFFF"/> L 8 4.25 C 6,5.25 5.5,5.25 5.125,5.25 L 2 5.25 C 0,5.25 0,5.25 0,9.25 z" Brush="#7FFFFFFF"/>
</DrawingGroup> </DrawingGroup>
<DrawingGroup x:Key="Icon_File"> <DrawingGroup x:Key="Icon_File">
<GeometryDrawing Geometry="M 0 0 L 16 16"/> <GeometryDrawing Geometry="M 0 0 L 16 16"/>
<GeometryDrawing Geometry="M 2 0 L 10 0 L 14 4 L 14 16 L 2 16 Z" Brush="#FF797774"/> <GeometryDrawing Geometry="M 2 0 L 10 0 L 14 4 L 14 16 L 2 16 Z" Brush="#FF797774"/>
<GeometryDrawing Geometry="M 3 1 L 9.7 1 L 13 4.3 L 13 15 L 3 15 Z" Brush="#FFFAFAFA"/> <GeometryDrawing Geometry="M 3 1 L 9.7 1 L 13 4.3 L 13 15 L 3 15 Z" Brush="#FFFAFAFA"/>
<GeometryDrawing Geometry="L 9 1 L 9 5 L 14 5 L 14 4 L 10 4 L 10 1 Z" Brush="#FF797774"/> <GeometryDrawing Geometry="L 9 1 L 9 5 L 14 5 L 14 4 L 10 4 L 10 1 Z" Brush="#FF797774"/>
</DrawingGroup> </DrawingGroup>
<DrawingGroup x:Key="Icon_Volume"> <DrawingGroup x:Key="Icon_Volume">
<GeometryDrawing Geometry="M 0 0 L 16 16"/> <GeometryDrawing Geometry="M 0 0 L 16 16"/>
<GeometryDrawing Geometry="M 4 5 L 12 5 L 14.5 7.5 C 15,8 15,8 15,9 L 1 9 C 1,8 1,8 1.5 7.5 Z" Brush="#FFE1E3E6"/> <GeometryDrawing Geometry="M 4 5 L 12 5 L 14.5 7.5 C 15,8 15,8 15,9 L 1 9 C 1,8 1,8 1.5 7.5 Z" Brush="#FFE1E3E6"/>
<GeometryDrawing Geometry="M 12 5 L 14.5 7.5 C 15,8 15,8 15,9 L 10 9 L 10 5 Z"> <GeometryDrawing Geometry="M 12 5 L 14.5 7.5 C 15,8 15,8 15,9 L 10 9 L 10 5 Z">
<GeometryDrawing.Brush> <GeometryDrawing.Brush>
<LinearGradientBrush StartPoint="12,5" EndPoint="11.5,5.5"> <LinearGradientBrush StartPoint="12,5" EndPoint="11.5,5.5">
<GradientStop Offset="0" Color="#FFCDCFD1"/> <GradientStop Offset="0" Color="#FFCDCFD1"/>
<GradientStop Offset="1" Color="#00CDCFD1"/> <GradientStop Offset="1" Color="#00CDCFD1"/>
</LinearGradientBrush> </LinearGradientBrush>
</GeometryDrawing.Brush> </GeometryDrawing.Brush>
</GeometryDrawing> </GeometryDrawing>
<GeometryDrawing Geometry="M 4 5 L 1.5 7.5 C 1,8 1,8 1,9 L 4 9 L 6 9 L 6 5 Z"> <GeometryDrawing Geometry="M 4 5 L 1.5 7.5 C 1,8 1,8 1,9 L 4 9 L 6 9 L 6 5 Z">
<GeometryDrawing.Brush> <GeometryDrawing.Brush>
<LinearGradientBrush StartPoint="4,5" EndPoint="4.5,5.5"> <LinearGradientBrush StartPoint="4,5" EndPoint="4.5,5.5">
<GradientStop Offset="0" Color="#FFCDCFD1"/> <GradientStop Offset="0" Color="#FFCDCFD1"/>
<GradientStop Offset="1" Color="#00CDCFD1"/> <GradientStop Offset="1" Color="#00CDCFD1"/>
</LinearGradientBrush> </LinearGradientBrush>
</GeometryDrawing.Brush> </GeometryDrawing.Brush>
</GeometryDrawing> </GeometryDrawing>
<GeometryDrawing Geometry="M 1 9 C 1,8 1,8 2,8 L 14 8 <GeometryDrawing Geometry="M 1 9 C 1,8 1,8 2,8 L 14 8
C 15,8 15,8 15,9 L 15 11 C 15,8 15,8 15,9 L 15 11
C 15,12 15,12 14,12 L 2 12 C 15,12 15,12 14,12 L 2 12
C 1,12 1,12 1,11 Z"> C 1,12 1,12 1,11 Z">
<GeometryDrawing.Brush> <GeometryDrawing.Brush>
<LinearGradientBrush StartPoint="0,8" EndPoint="0,12"> <LinearGradientBrush StartPoint="0,8" EndPoint="0,12">
<GradientStop Offset="0" Color="#FF737374"/> <GradientStop Offset="0" Color="#FF737374"/>
<GradientStop Offset="1" Color="#FFA8A8A8"/> <GradientStop Offset="1" Color="#FFA8A8A8"/>
</LinearGradientBrush> </LinearGradientBrush>
</GeometryDrawing.Brush> </GeometryDrawing.Brush>
</GeometryDrawing> </GeometryDrawing>
<GeometryDrawing Geometry="M 2 9 C 2,8 2,8 3,8 L 13 8 <GeometryDrawing Geometry="M 2 9 C 2,8 2,8 3,8 L 13 8
C 14,8 14,8 14,9 L 14 10 C 14,8 14,8 14,9 L 14 10
C 14,11 14,11 13,11 L 3 11 C 14,11 14,11 13,11 L 3 11
C 2,11 2,11 2,10 Z"> C 2,11 2,11 2,10 Z">
<GeometryDrawing.Brush> <GeometryDrawing.Brush>
<LinearGradientBrush StartPoint="0,8" EndPoint="0,11"> <LinearGradientBrush StartPoint="0,8" EndPoint="0,11">
<GradientStop Offset="0" Color="#FF333333"/> <GradientStop Offset="0" Color="#FF333333"/>
<GradientStop Offset="1" Color="#FF5A5A5A"/> <GradientStop Offset="1" Color="#FF5A5A5A"/>
</LinearGradientBrush> </LinearGradientBrush>
</GeometryDrawing.Brush> </GeometryDrawing.Brush>
</GeometryDrawing> </GeometryDrawing>
<GeometryDrawing> <GeometryDrawing>
<GeometryDrawing.Geometry> <GeometryDrawing.Geometry>
<EllipseGeometry Rect="2.5,8.5,2,2"/> <EllipseGeometry Rect="2.5,8.5,2,2"/>
</GeometryDrawing.Geometry> </GeometryDrawing.Geometry>
<GeometryDrawing.Brush> <GeometryDrawing.Brush>
<RadialGradientBrush GradientOrigin="3.5,9.5" Center="3.5,9.5"> <RadialGradientBrush GradientOrigin="3.5,9.5" Center="3.5,9.5">
<GradientStop Offset="0.8" Color="#4001FF01"/> <GradientStop Offset="0.8" Color="#4001FF01"/>
<GradientStop Offset="1" Color="#0001FF01"/> <GradientStop Offset="1" Color="#0001FF01"/>
</RadialGradientBrush> </RadialGradientBrush>
</GeometryDrawing.Brush> </GeometryDrawing.Brush>
</GeometryDrawing> </GeometryDrawing>
<GeometryDrawing> <GeometryDrawing>
<GeometryDrawing.Geometry> <GeometryDrawing.Geometry>
<EllipseGeometry Rect="3,9,1,1"/> <EllipseGeometry Rect="3,9,1,1"/>
</GeometryDrawing.Geometry> </GeometryDrawing.Geometry>
<GeometryDrawing.Brush> <GeometryDrawing.Brush>
<RadialGradientBrush GradientOrigin="3.5,9.5" Center="3.25,9.75"> <RadialGradientBrush GradientOrigin="3.5,9.5" Center="3.25,9.75">
<GradientStop Offset="0" Color="#FFB6FFB6"/> <GradientStop Offset="0" Color="#FFB6FFB6"/>
<GradientStop Offset="1" Color="#FF01FF01"/> <GradientStop Offset="1" Color="#FF01FF01"/>
</RadialGradientBrush> </RadialGradientBrush>
</GeometryDrawing.Brush> </GeometryDrawing.Brush>
</GeometryDrawing> </GeometryDrawing>
<GeometryDrawing Geometry="M 3.23483495705 9.76516504295 A 0.375,0.375 180 1 0 3.76516504295,9.23483495705 A 0.4375,0.4375 135 0 1 3.23483495705,9.76516504295 Z" Brush="#FF00B300"/> <GeometryDrawing Geometry="M 3.23483495705 9.76516504295 A 0.375,0.375 180 1 0 3.76516504295,9.23483495705 A 0.4375,0.4375 135 0 1 3.23483495705,9.76516504295 Z" Brush="#FF00B300"/>
</DrawingGroup> </DrawingGroup>
</dialogs:ResourceSelectorConverter> </dialogs:ResourceSelectorConverter>
</ResourceDictionary> </ResourceDictionary>
</Style.Resources> </ControlTheme.Resources>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate>
<DockPanel>
<ListBox x:Name="QuickLinks" DockPanel.Dock="Left" Items="{Binding QuickLinks}" SelectedIndex="{Binding QuickLinksSelectedIndex}" Focusable="False">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Spacing="4" Orientation="Horizontal" Background="Transparent">
<DrawingPresenter Width="16" Height="16" Drawing="{Binding IconKey, Converter={StaticResource Icons}}"/>
<TextBlock Text="{Binding DisplayName}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<DockPanel x:Name="NavBar" DockPanel.Dock="Top" Margin="8,5,8,0" VerticalAlignment="Center">
<Rectangle Fill="{DynamicResource SystemControlHighlightAltBaseMediumLowBrush}" Height="1" Margin="0,5,0,0" DockPanel.Dock="Bottom"/>
<DockPanel Margin="4,0">
<Button Command="{Binding GoUp}" DockPanel.Dock="Left">
<Path Data="M 0 7 L 7 0 L 14 7 M 7 0 L 7 16" Stroke="{CompiledBinding $parent[Button].Foreground}" StrokeThickness="1" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,1,0,-1"/>
</Button>
<TextBox x:Name="Location" Text="{Binding Location}">
<TextBox.KeyBindings>
<KeyBinding Command="{Binding EnterPressed}" Gesture="Enter"/>
</TextBox.KeyBindings>
</TextBox>
</DockPanel>
</DockPanel>
<DockPanel Margin="8,0,8,5" DockPanel.Dock="Bottom">
<Rectangle Fill="{DynamicResource SystemControlHighlightAltBaseMediumLowBrush}" Height="1" Margin="0,0,0,5" DockPanel.Dock="Top"/>
<DockPanel Margin="4,0">
<DockPanel DockPanel.Dock="Top" Margin="0,0,0,4">
<ComboBox DockPanel.Dock="Right"
IsVisible="{Binding ShowFilters}"
Items="{Binding Filters}"
SelectedItem="{Binding SelectedFilter}" />
<TextBox Text="{Binding FileName}" Watermark="File name" IsVisible="{Binding !SelectingFolder}" />
</DockPanel>
<CheckBox IsChecked="{Binding ShowHiddenFiles}" Content="Show hidden files" DockPanel.Dock="Left"/>
<UniformGrid x:Name="Finalize" HorizontalAlignment="Right" Rows="1">
<Button Command="{Binding Ok}">OK</Button>
<Button Command="{Binding Cancel}">Cancel</Button>
</UniformGrid>
</DockPanel>
</DockPanel>
<DockPanel Grid.IsSharedSizeScope="True">
<Grid DockPanel.Dock="Top" Margin="15 5 0 0" HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20" SharedSizeGroup="Icon" />
<ColumnDefinition Width="16" SharedSizeGroup="Splitter" />
<ColumnDefinition Width="275" SharedSizeGroup="Name" />
<ColumnDefinition Width="16" SharedSizeGroup="Splitter" />
<ColumnDefinition Width="200" SharedSizeGroup="Modified" />
<ColumnDefinition Width="16" SharedSizeGroup="Splitter" />
<ColumnDefinition Width="150" SharedSizeGroup="Type" />
<ColumnDefinition Width="16" SharedSizeGroup="Splitter" />
<ColumnDefinition Width="200" SharedSizeGroup="Size" />
</Grid.ColumnDefinitions>
<Grid.Styles>
<Style Selector="GridSplitter">
<Setter Property="Background" Value="{DynamicResource SystemControlHighlightAltBaseMediumLowBrush}"/>
<Setter Property="Template">
<ControlTemplate>
<Border VerticalAlignment="Stretch" BorderThickness="0" Background="#01000000">
<Rectangle Width="1" VerticalAlignment="Stretch" Fill="{TemplateBinding Background}"/>
</Border>
</ControlTemplate>
</Setter>
</Style>
</Grid.Styles>
<GridSplitter Grid.Column="1" />
<TextBlock Grid.Column="2" Text="Name" />
<GridSplitter Grid.Column="3" />
<TextBlock Grid.Column="4" Text="Date Modified" />
<GridSplitter Grid.Column="5" />
<TextBlock Grid.Column="6" Text="Type" />
<GridSplitter Grid.Column="7" />
<TextBlock Grid.Column="8" Text="Size" />
</Grid>
<ListBox x:Name="Files"
VirtualizationMode="Simple"
Items="{Binding Items}"
Margin="0 5"
SelectionMode="{Binding SelectionMode}"
SelectedItems="{Binding SelectedItems}"
Background="Transparent"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Background="Transparent">
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="Icon" />
<ColumnDefinition SharedSizeGroup="Splitter" />
<ColumnDefinition SharedSizeGroup="Name" />
<ColumnDefinition SharedSizeGroup="Splitter" />
<ColumnDefinition SharedSizeGroup="Modified" />
<ColumnDefinition SharedSizeGroup="Splitter" />
<ColumnDefinition SharedSizeGroup="Type" />
<ColumnDefinition SharedSizeGroup="Splitter" />
<ColumnDefinition SharedSizeGroup="Size" />
</Grid.ColumnDefinitions>
<DrawingPresenter Width="16" Height="16" Drawing="{Binding IconKey, Converter={StaticResource Icons}}"/>
<TextBlock Grid.Column="2" Text="{Binding DisplayName}"/>
<TextBlock Grid.Column="4" Text="{Binding Modified}" />
<TextBlock Grid.Column="6" Text="{Binding Type}" />
<TextBlock Grid.Column="8">
<TextBlock.Text>
<Binding Path="Size">
<Binding.Converter>
<dialogs:FileSizeStringConverter/>
</Binding.Converter>
</Binding>
</TextBlock.Text>
</TextBlock>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DockPanel>
</DockPanel>
</ControlTemplate>
</Setter>
<Style Selector="^ /template/ ListBox#QuickLinks">
<Setter Property="Margin" Value="0"/>
<Setter Property="Background" Value="{DynamicResource SystemControlBackgroundChromeMediumBrush}"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Width" Value="240"/>
<Setter Property="Padding" Value="0,20"/>
<Setter Property="Template">
<ControlTemplate>
<Border Name="border" BoxShadow="inset -6 0 3 -3 #20000000" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<ScrollViewer Name="PART_ScrollViewer" HorizontalScrollBarVisibility="{TemplateBinding (ScrollViewer.HorizontalScrollBarVisibility)}" VerticalScrollBarVisibility="{TemplateBinding (ScrollViewer.VerticalScrollBarVisibility)}">
<ItemsPresenter Name="PART_ItemsPresenter"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}"
ItemTemplate="{TemplateBinding ItemTemplate}"
Margin="{TemplateBinding Padding}"
VirtualizationMode="{TemplateBinding VirtualizationMode}"/>
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter>
<Setter Property="ItemContainerTheme">
<ControlTheme TargetType="ListBoxItem">
<Setter Property="Height" Value="32"/>
<Setter Property="Padding" Value="30,6"/>
<Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<DockPanel> <Border x:Name="LayoutRoot" CornerRadius="2" Margin="10,0">
<ListBox x:Name="QuickLinks" DockPanel.Dock="Left" Items="{Binding QuickLinks}" SelectedIndex="{Binding QuickLinksSelectedIndex}" Focusable="False"> <Panel>
<ListBox.ItemTemplate> <Border x:Name="SelectedLine" HorizontalAlignment="Left" Margin="2,6" CornerRadius="0.5" Width="3" Background="{DynamicResource SystemControlHighlightAccentBrush}" IsVisible="{TemplateBinding IsSelected}"/>
<DataTemplate> <ContentPresenter Name="PART_ContentPresenter"
<StackPanel Spacing="4" Orientation="Horizontal" Background="Transparent"> Background="Transparent"
<DrawingPresenter Width="16" Height="16" Drawing="{Binding IconKey, Converter={StaticResource Icons}}"/> BorderBrush="Transparent"
<TextBlock Text="{Binding DisplayName}"/> BorderThickness="0"
</StackPanel> ContentTemplate="{TemplateBinding ContentTemplate}"
</DataTemplate> Content="{TemplateBinding Content}"
</ListBox.ItemTemplate> Padding="{TemplateBinding Padding}"
</ListBox> VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
<DockPanel x:Name="NavBar" DockPanel.Dock="Top" Margin="8,5,8,0" VerticalAlignment="Center"> HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"/>
<Rectangle Fill="{DynamicResource SystemControlHighlightAltBaseMediumLowBrush}" Height="1" Margin="0,5,0,0" DockPanel.Dock="Bottom"/>
<DockPanel Margin="4,0">
<Button Command="{Binding GoUp}" DockPanel.Dock="Left">
<Path Data="M 0 7 L 7 0 L 14 7 M 7 0 L 7 16" Stroke="{CompiledBinding $parent[Button].Foreground}" StrokeThickness="1" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,1,0,-1"/>
</Button>
<TextBox x:Name="Location" Text="{Binding Location}">
<TextBox.KeyBindings>
<KeyBinding Command="{Binding EnterPressed}" Gesture="Enter"/>
</TextBox.KeyBindings>
</TextBox>
</DockPanel>
</DockPanel>
<DockPanel Margin="8,0,8,5" DockPanel.Dock="Bottom">
<Rectangle Fill="{DynamicResource SystemControlHighlightAltBaseMediumLowBrush}" Height="1" Margin="0,0,0,5" DockPanel.Dock="Top"/>
<DockPanel Margin="4,0">
<DockPanel DockPanel.Dock="Top" Margin="0,0,0,4">
<ComboBox DockPanel.Dock="Right"
IsVisible="{Binding ShowFilters}"
Items="{Binding Filters}"
SelectedItem="{Binding SelectedFilter}" />
<TextBox Text="{Binding FileName}" Watermark="File name" IsVisible="{Binding !SelectingFolder}" />
</DockPanel>
<CheckBox IsChecked="{Binding ShowHiddenFiles}" Content="Show hidden files" DockPanel.Dock="Left"/>
<UniformGrid x:Name="Finalize" HorizontalAlignment="Right" Rows="1">
<Button Command="{Binding Ok}">OK</Button>
<Button Command="{Binding Cancel}">Cancel</Button>
</UniformGrid>
</DockPanel>
</DockPanel>
<DockPanel Grid.IsSharedSizeScope="True"> </Panel>
<Grid DockPanel.Dock="Top" Margin="15 5 0 0" HorizontalAlignment="Stretch"> </Border>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20" SharedSizeGroup="Icon" />
<ColumnDefinition Width="16" SharedSizeGroup="Splitter" />
<ColumnDefinition Width="275" SharedSizeGroup="Name" />
<ColumnDefinition Width="16" SharedSizeGroup="Splitter" />
<ColumnDefinition Width="200" SharedSizeGroup="Modified" />
<ColumnDefinition Width="16" SharedSizeGroup="Splitter" />
<ColumnDefinition Width="150" SharedSizeGroup="Type" />
<ColumnDefinition Width="16" SharedSizeGroup="Splitter" />
<ColumnDefinition Width="200" SharedSizeGroup="Size" />
</Grid.ColumnDefinitions>
<Grid.Styles>
<Style Selector="GridSplitter">
<Setter Property="Background" Value="{DynamicResource SystemControlHighlightAltBaseMediumLowBrush}"/>
<Setter Property="Template">
<ControlTemplate>
<Border VerticalAlignment="Stretch" BorderThickness="0" Background="#01000000">
<Rectangle Width="1" VerticalAlignment="Stretch" Fill="{TemplateBinding Background}"/>
</Border>
</ControlTemplate>
</Setter>
</Style>
</Grid.Styles>
<GridSplitter Grid.Column="1" />
<TextBlock Grid.Column="2" Text="Name" />
<GridSplitter Grid.Column="3" />
<TextBlock Grid.Column="4" Text="Date Modified" />
<GridSplitter Grid.Column="5" />
<TextBlock Grid.Column="6" Text="Type" />
<GridSplitter Grid.Column="7" />
<TextBlock Grid.Column="8" Text="Size" />
</Grid>
<ListBox x:Name="Files"
VirtualizationMode="Simple"
Items="{Binding Items}"
Margin="0 5"
SelectionMode="{Binding SelectionMode}"
SelectedItems="{Binding SelectedItems}"
Background="Transparent"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Background="Transparent">
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="Icon" />
<ColumnDefinition SharedSizeGroup="Splitter" />
<ColumnDefinition SharedSizeGroup="Name" />
<ColumnDefinition SharedSizeGroup="Splitter" />
<ColumnDefinition SharedSizeGroup="Modified" />
<ColumnDefinition SharedSizeGroup="Splitter" />
<ColumnDefinition SharedSizeGroup="Type" />
<ColumnDefinition SharedSizeGroup="Splitter" />
<ColumnDefinition SharedSizeGroup="Size" />
</Grid.ColumnDefinitions>
<DrawingPresenter Width="16" Height="16" Drawing="{Binding IconKey, Converter={StaticResource Icons}}"/>
<TextBlock Grid.Column="2" Text="{Binding DisplayName}"/>
<TextBlock Grid.Column="4" Text="{Binding Modified}" />
<TextBlock Grid.Column="6" Text="{Binding Type}" />
<TextBlock Grid.Column="8">
<TextBlock.Text>
<Binding Path="Size">
<Binding.Converter>
<dialogs:FileSizeStringConverter/>
</Binding.Converter>
</Binding>
</TextBlock.Text>
</TextBlock>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DockPanel>
</DockPanel>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style>
<Style Selector="^:pointerover /template/ Border#LayoutRoot">
<Style Selector="dialogs|ManagedFileChooser /template/ ListBox#QuickLinks"> <Setter Property="Background" Value="{DynamicResource SystemControlBackgroundAltMediumBrush}"/>
<Setter Property="Margin" Value="0"/> </Style>
<Setter Property="Background" Value="{DynamicResource SystemControlBackgroundChromeMediumBrush}"/> <Style Selector="^:selected /template/ Border#LayoutRoot">
<Setter Property="BorderThickness" Value="0"/> <Setter Property="Background" Value="{DynamicResource SystemControlBackgroundAltMediumHighBrush}"/>
<Setter Property="Width" Value="240"/> </Style>
<Setter Property="Padding" Value="0,20"/> </ControlTheme>
<Setter Property="Template"> </Setter>
<ControlTemplate>
<Border Name="border" BoxShadow="inset -6 0 3 -3 #20000000" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<ScrollViewer Name="PART_ScrollViewer" HorizontalScrollBarVisibility="{TemplateBinding (ScrollViewer.HorizontalScrollBarVisibility)}" VerticalScrollBarVisibility="{TemplateBinding (ScrollViewer.VerticalScrollBarVisibility)}">
<ItemsPresenter Name="PART_ItemsPresenter"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}"
ItemTemplate="{TemplateBinding ItemTemplate}"
Margin="{TemplateBinding Padding}"
VirtualizationMode="{TemplateBinding VirtualizationMode}"/>
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter>
</Style> </Style>
<Style Selector="dialogs|ManagedFileChooser /template/ ListBox#QuickLinks ListBoxItem">
<Setter Property="Height" Value="32"/>
<Setter Property="Padding" Value="30,6"/>
<Setter Property="Template">
<ControlTemplate>
<Border x:Name="LayoutRoot" CornerRadius="2" Margin="10,0">
<Panel>
<Border x:Name="SelectedLine" HorizontalAlignment="Left" Margin="2,6" CornerRadius="0.5" Width="3" Background="{DynamicResource SystemControlHighlightAccentBrush}" IsVisible="{TemplateBinding IsSelected}"/>
<ContentPresenter Name="PART_ContentPresenter"
Background="Transparent"
BorderBrush="Transparent"
BorderThickness="0"
ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"
Padding="{TemplateBinding Padding}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"/>
</Panel> <Style Selector="^ /template/ DockPanel#NavBar Button, ^ /template/ DockPanel#NavBar TextBox">
</Border> <Setter Property="Height" Value="30"/>
</ControlTemplate>
</Setter>
</Style>
<Style Selector="dialogs|ManagedFileChooser /template/ ListBox#QuickLinks ListBoxItem:pointerover /template/ Border#LayoutRoot">
<Setter Property="Background" Value="{DynamicResource SystemControlBackgroundAltMediumBrush}"/>
</Style> </Style>
<Style Selector="dialogs|ManagedFileChooser /template/ ListBox#QuickLinks ListBoxItem:selected /template/ Border#LayoutRoot"> <Style Selector="^ /template/ DockPanel#NavBar Button">
<Setter Property="Background" Value="{DynamicResource SystemControlBackgroundAltMediumHighBrush}"/> <Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="Width" Value="40"/>
<Setter Property="Margin" Value="0,0,8,0"/>
<Setter Property="BorderThickness" Value="0"/>
</Style> </Style>
<Style Selector="dialogs|ManagedFileChooser /template/ DockPanel#NavBar Button, <Style Selector="^ /template/ DockPanel#NavBar Button:not(:pointerover):not(:pressed)">
dialogs|ManagedFileChooser /template/ DockPanel#NavBar TextBox"> <Setter Property="Background" Value="Transparent"/>
<Setter Property="Height" Value="30"/>
</Style>
<Style Selector="dialogs|ManagedFileChooser /template/ DockPanel#NavBar Button">
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="Width" Value="40"/>
<Setter Property="Margin" Value="0,0,8,0"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>
<Style Selector="dialogs|ManagedFileChooser /template/ DockPanel#NavBar Button:not(:pointerover):not(:pressed)">
<Setter Property="Background" Value="Transparent"/>
</Style> </Style>
<Style Selector="dialogs|ManagedFileChooser /template/ UniformGrid#Finalize > Button"> <Style Selector="^ /template/ UniformGrid#Finalize > Button">
<Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/> <Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="Margin" Value="4,0,0,0"/> <Setter Property="Margin" Value="4,0,0,0"/>
</Style>
<Style Selector="dialogs|ManagedFileChooser /template/ UniformGrid#Finalize > Button /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
</Style> </Style>
</Styles> </ControlTheme>
</ResourceDictionary>

133
src/Avalonia.Themes.Fluent/Controls/Menu.xaml

@ -1,36 +1,113 @@
<Style xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
Selector="Menu">
<Design.PreviewWith> <Design.PreviewWith>
<Border Padding="20"> <Border Padding="20">
<Menu> <Menu>
<MenuItem Header="New" /> <MenuItem Header="_Standard" />
<MenuItem Header="Open" /> <MenuItem Header="Selected" IsSelected="True" />
<MenuItem Header="Disabled" IsEnabled="False"/>
</Menu> </Menu>
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Style.Resources> <x:Double x:Key="MenuBarHeight">32</x:Double>
<x:Double x:Key="MenuBarHeight">32</x:Double>
</Style.Resources>
<Setter Property="Background" Value="Transparent" /> <ControlTheme x:Key="FluentTopLevelMenuItem" TargetType="MenuItem">
<Setter Property="Height" Value="{DynamicResource MenuBarHeight}" /> <Setter Property="Background" Value="{DynamicResource MenuFlyoutItemBackground}" />
<Setter Property="Template"> <Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemForeground}" />
<ControlTemplate> <!-- Narrow padding should be used for mouse input, when non-narrow one should be used for touch input in future. -->
<Border Background="{TemplateBinding Background}" <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
BorderBrush="{TemplateBinding BorderBrush}" <Setter Property="Padding" Value="{DynamicResource MenuBarItemPadding}" />
BorderThickness="{TemplateBinding BorderThickness}" <Setter Property="Template">
CornerRadius="{TemplateBinding CornerRadius}" <ControlTemplate>
HorizontalAlignment="Stretch" <Border Name="PART_LayoutRoot"
Padding="{TemplateBinding Padding}"> Background="{TemplateBinding Background}"
<ItemsPresenter Name="PART_ItemsPresenter" BorderBrush="{TemplateBinding BorderBrush}"
Items="{TemplateBinding Items}" BorderThickness="{TemplateBinding BorderThickness}"
ItemsPanel="{TemplateBinding ItemsPanel}" CornerRadius="{TemplateBinding CornerRadius}">
ItemTemplate="{TemplateBinding ItemTemplate}" <Panel>
VerticalAlignment="Stretch" <ContentPresenter Name="PART_HeaderPresenter"
KeyboardNavigation.TabNavigation="Continue" /> Content="{TemplateBinding Header}"
</Border> VerticalAlignment="Center"
</ControlTemplate> HorizontalAlignment="Stretch"
</Setter> RecognizesAccessKey="True"
</Style> Margin="{TemplateBinding Padding}"/>
<Popup Name="PART_Popup"
WindowManagerAddShadowHint="False"
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
IsLightDismissEnabled="True"
IsOpen="{TemplateBinding IsSubMenuOpen, Mode=TwoWay}"
OverlayInputPassThroughElement="{Binding $parent[Menu]}">
<Border Background="{DynamicResource MenuFlyoutPresenterBackground}"
BorderBrush="{DynamicResource MenuFlyoutPresenterBorderBrush}"
BorderThickness="{DynamicResource MenuFlyoutPresenterBorderThemeThickness}"
Padding="{DynamicResource MenuFlyoutPresenterThemePadding}"
MaxWidth="{DynamicResource FlyoutThemeMaxWidth}"
MinHeight="{DynamicResource MenuFlyoutThemeMinHeight}"
HorizontalAlignment="Stretch"
CornerRadius="{DynamicResource OverlayCornerRadius}">
<ScrollViewer Classes="menuscroller">
<ItemsPresenter Name="PART_ItemsPresenter"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}"
ItemTemplate="{TemplateBinding ItemTemplate}"
Margin="{DynamicResource MenuFlyoutScrollerMargin}"
Grid.IsSharedSizeScope="True" />
</ScrollViewer>
</Border>
</Popup>
</Panel>
</Border>
</ControlTemplate>
</Setter>
<Style Selector="^:selected">
<Style Selector="^ /template/ Border#PART_LayoutRoot">
<Setter Property="Background" Value="{DynamicResource MenuFlyoutItemBackgroundPointerOver}" />
</Style>
<Style Selector="^ /template/ ContentPresenter#PART_HeaderPresenter">
<Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemForegroundPointerOver}" />
</Style>
</Style>
<!-- Listen for PART_LayoutRoot:pointerover, so it will not be triggered when subitem is pressed -->
<Style Selector="^:pressed /template/ Border#PART_LayoutRoot:pointerover">
<Setter Property="Background" Value="{DynamicResource MenuFlyoutItemBackgroundPressed}" />
<Style Selector="^ ContentPresenter#PART_HeaderPresenter">
<Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemForegroundPressed}" />
</Style>
</Style>
<Style Selector="^:disabled">
<Style Selector="^ /template/ Border#PART_LayoutRoot">
<Setter Property="Background" Value="{DynamicResource MenuFlyoutItemBackgroundDisabled}" />
</Style>
<Style Selector="^ /template/ ContentPresenter#PART_HeaderPresenter">
<Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemForegroundDisabled}" />
</Style>
</Style>
</ControlTheme>
<ControlTheme x:Key="{x:Type Menu}" TargetType="Menu">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Height" Value="{DynamicResource MenuBarHeight}" />
<Setter Property="ItemContainerTheme" Value="{StaticResource FluentTopLevelMenuItem}"/>
<Setter Property="Template">
<ControlTemplate>
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
HorizontalAlignment="Stretch"
Padding="{TemplateBinding Padding}">
<ItemsPresenter Name="PART_ItemsPresenter"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}"
ItemTemplate="{TemplateBinding ItemTemplate}"
VerticalAlignment="Stretch"
KeyboardNavigation.TabNavigation="Continue" />
</Border>
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>

10
src/Avalonia.Themes.Fluent/Controls/MenuFlyoutPresenter.xaml

@ -1,6 +1,6 @@
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style Selector="MenuFlyoutPresenter"> <ControlTheme x:Key="{x:Type MenuFlyoutPresenter}" TargetType="MenuFlyoutPresenter">
<Setter Property="Background" Value="{DynamicResource MenuFlyoutPresenterBackground}" /> <Setter Property="Background" Value="{DynamicResource MenuFlyoutPresenterBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource MenuFlyoutPresenterBorderBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource MenuFlyoutPresenterBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource MenuFlyoutPresenterBorderThemeThickness}" /> <Setter Property="BorderThickness" Value="{DynamicResource MenuFlyoutPresenterBorderThemeThickness}" />
@ -31,5 +31,5 @@
</Border> </Border>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> </ControlTheme>
</Styles> </ResourceDictionary>

322
src/Avalonia.Themes.Fluent/Controls/MenuItem.xaml

@ -1,60 +1,67 @@
<Styles xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:conv="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls" xmlns:conv="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls"
xmlns:sys="clr-namespace:System;assembly=netstandard" xmlns:sys="clr-namespace:System;assembly=netstandard"
x:DataType="MenuItem" x:DataType="MenuItem"
x:CompileBindings="True"> x:CompileBindings="True">
<Design.PreviewWith> <Design.PreviewWith>
<Border Padding="20" <Border Padding="20" Width="320">
Width="400" <StackPanel Spacing="20" HorizontalAlignment="Left">
Height="200"> <MenuItem Header="_Standard"/>
<Menu VerticalAlignment="Top"> <MenuItem IsSelected="True" Header="Selected"/>
<MenuItem Header="File"> <MenuItem Header="With Icon">
<MenuItem Header="Disabled" <MenuItem.Icon>
IsEnabled="False" /> <TextBlock>😊</TextBlock>
<MenuItem Header="New" </MenuItem.Icon>
InputGesture="Ctrl+N">
<MenuItem Header="XML" />
</MenuItem>
<MenuItem Header="Open">
<MenuItem.Icon>
<CheckBox BorderThickness="0"
IsHitTestVisible="False"
IsChecked="True" />
</MenuItem.Icon>
</MenuItem>
<Separator />
<MenuItem Header="Exit"
InputGesture="Alt+F4" />
</MenuItem> </MenuItem>
<MenuItem Header="Edit"> <MenuItem Header="With CheckBox">
<MenuItem Header="Go To"> <MenuItem.Icon>
<MenuItem Header="Go To Line" /> <CheckBox IsChecked="True"/>
</MenuItem> </MenuItem.Icon>
</MenuItem> </MenuItem>
<MenuItem Header="View"> <MenuItem Header="Input Gesture" InputGesture="Ctrl+G"/>
<MenuItem Header="Designer" <MenuItem Header="Disabled" IsEnabled="False"/>
InputGesture="Shift+F7" /> <MenuItem Header="-"/>
<MenuItem Header="Parent" IsSubMenuOpen="True">
<MenuItem Header="Child 1"/>
<MenuItem Header="Child 2"/>
<MenuItem Header="Child 3"/>
<Separator/>
<MenuItem Header="Child 4"/>
<MenuItem Header="Child 5"/>
<MenuItem Header="Child 6"/>
<MenuItem Header="Child 7"/>
<MenuItem Header="Child 8"/>
<MenuItem Header="Child 9"/>
<MenuItem Header="Child 10"/>
<MenuItem Header="Child 11"/>
<MenuItem Header="Child 12"/>
<MenuItem Header="Child 13"/>
<MenuItem Header="Child 14"/>
<MenuItem Header="Child 15"/>
<MenuItem Header="Child 16"/>
<MenuItem Header="Child 17"/>
<MenuItem Header="Child 18"/>
<MenuItem Header="Child 19"/>
</MenuItem> </MenuItem>
<MenuItem Header="Project"> <MenuItem Header="Disabled Parent" IsEnabled="False">
<MenuItem Header="Add class" /> <MenuItem Header="Child"/>
</MenuItem> </MenuItem>
</Menu> </StackPanel>
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Styles.Resources> <conv:PlatformKeyGestureConverter x:Key="KeyGestureConverter" />
<conv:PlatformKeyGestureConverter x:Key="KeyGestureConverter" /> <x:Double x:Key="MenuFlyoutSubItemPopupHorizontalOffset">-4</x:Double>
<x:Double x:Key="MenuFlyoutSubItemPopupHorizontalOffset">-4</x:Double> <Thickness x:Key="MenuIconPresenterMargin">0,0,12,0</Thickness>
<Thickness x:Key="MenuIconPresenterMargin">0,0,12,0</Thickness> <Thickness x:Key="MenuInputGestureTextMargin">24,0,0,0</Thickness>
<Thickness x:Key="MenuInputGestureTextMargin">24,0,0,0</Thickness> <StreamGeometry x:Key="MenuItemChevronPathData">M 1,0 10,10 l -9,10 -1,-1 L 8,10 -0,1 Z</StreamGeometry>
<StreamGeometry x:Key="MenuItemChevronPathData">M 1,0 10,10 l -9,10 -1,-1 L 8,10 -0,1 Z</StreamGeometry>
</Styles.Resources>
<Style Selector="MenuItem"> <ControlTheme x:Key="{x:Type MenuItem}" TargetType="MenuItem">
<Setter Property="Background" Value="{DynamicResource MenuFlyoutItemBackground}" /> <Setter Property="Background" Value="{DynamicResource MenuFlyoutItemBackground}" />
<Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemForeground}" /> <Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemForeground}" />
<Setter Property="Padding" Value="{DynamicResource MenuFlyoutItemThemePadding}" /> <!-- Narrow padding should be used for mouse input, when non-narrow one should be used for touch input in future. -->
<Setter Property="Padding" Value="{DynamicResource MenuFlyoutItemThemePaddingNarrow}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
@ -75,35 +82,37 @@
<ColumnDefinition Width="Auto" <ColumnDefinition Width="Auto"
SharedSizeGroup="MenuItemChevron" /> SharedSizeGroup="MenuItemChevron" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<ContentPresenter Name="PART_IconPresenter"
Content="{TemplateBinding Icon}" <Viewbox Name="PART_IconPresenter"
Margin="{DynamicResource MenuIconPresenterMargin}" Margin="{DynamicResource MenuIconPresenterMargin}"
HorizontalAlignment="Center" StretchDirection="DownOnly"
VerticalAlignment="Center" /> HorizontalAlignment="Center"
VerticalAlignment="Center"
IsVisible="False"
Width="16" Height="16">
<ContentPresenter Content="{TemplateBinding Icon}"/>
</Viewbox>
<ContentPresenter Name="PART_HeaderPresenter" <ContentPresenter Name="PART_HeaderPresenter"
Content="{TemplateBinding Header}" Content="{TemplateBinding Header}"
VerticalAlignment="Center" VerticalAlignment="Center"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
Grid.Column="1"> RecognizesAccessKey="True"
<ContentPresenter.DataTemplates> Grid.Column="1"/>
<DataTemplate DataType="sys:String">
<AccessText Text="{Binding}" />
</DataTemplate>
</ContentPresenter.DataTemplates>
</ContentPresenter>
<TextBlock x:Name="PART_InputGestureText" <TextBlock x:Name="PART_InputGestureText"
Grid.Column="2" Grid.Column="2"
Classes="CaptionTextBlockStyle" Classes="CaptionTextBlockStyle"
Margin="{DynamicResource MenuInputGestureTextMargin}" Margin="{DynamicResource MenuInputGestureTextMargin}"
Text="{TemplateBinding InputGesture, Converter={StaticResource KeyGestureConverter}}" Text="{TemplateBinding InputGesture, Converter={StaticResource KeyGestureConverter}}"
HorizontalAlignment="Right" HorizontalAlignment="Right"
VerticalAlignment="Center" /> VerticalAlignment="Center"
Foreground="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForeground}"/>
<Path Name="PART_ChevronPath" <Path Name="PART_ChevronPath"
Stretch="Uniform" Stretch="Uniform"
Width="8" Width="8"
Height="16" Height="16"
Data="{StaticResource MenuItemChevronPathData}" Data="{StaticResource MenuItemChevronPathData}"
Fill="{DynamicResource MenuFlyoutSubItemChevron}"
Margin="{DynamicResource MenuFlyoutItemChevronMargin}" Margin="{DynamicResource MenuFlyoutItemChevronMargin}"
VerticalAlignment="Center" VerticalAlignment="Center"
Grid.Column="3" /> Grid.Column="3" />
@ -123,7 +132,7 @@
MinHeight="{DynamicResource MenuFlyoutThemeMinHeight}" MinHeight="{DynamicResource MenuFlyoutThemeMinHeight}"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
CornerRadius="{DynamicResource OverlayCornerRadius}"> CornerRadius="{DynamicResource OverlayCornerRadius}">
<ScrollViewer Classes="menuscroller"> <ScrollViewer Theme="{StaticResource FluentMenuScrollViewer}">
<ItemsPresenter Name="PART_ItemsPresenter" <ItemsPresenter Name="PART_ItemsPresenter"
Items="{TemplateBinding Items}" Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}" ItemsPanel="{TemplateBinding ItemsPanel}"
@ -136,144 +145,69 @@
</Panel> </Panel>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style>
<Style Selector="Menu > MenuItem">
<Setter Property="Template">
<ControlTemplate>
<Border Name="PART_LayoutRoot"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<Panel>
<ContentPresenter Name="PART_HeaderPresenter"
Content="{TemplateBinding Header}"
VerticalAlignment="Center"
HorizontalAlignment="Stretch"
Margin="{TemplateBinding Padding}">
<ContentPresenter.DataTemplates>
<DataTemplate DataType="sys:String">
<AccessText Text="{Binding}" />
</DataTemplate>
</ContentPresenter.DataTemplates>
</ContentPresenter>
<Popup Name="PART_Popup"
WindowManagerAddShadowHint="False"
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
IsLightDismissEnabled="True"
IsOpen="{TemplateBinding IsSubMenuOpen, Mode=TwoWay}"
OverlayInputPassThroughElement="{Binding $parent[Menu]}">
<Border Background="{DynamicResource MenuFlyoutPresenterBackground}"
BorderBrush="{DynamicResource MenuFlyoutPresenterBorderBrush}"
BorderThickness="{DynamicResource MenuFlyoutPresenterBorderThemeThickness}"
Padding="{DynamicResource MenuFlyoutPresenterThemePadding}"
MaxWidth="{DynamicResource FlyoutThemeMaxWidth}"
MinHeight="{DynamicResource MenuFlyoutThemeMinHeight}"
HorizontalAlignment="Stretch"
CornerRadius="{DynamicResource OverlayCornerRadius}">
<ScrollViewer Classes="menuscroller">
<ItemsPresenter Name="PART_ItemsPresenter"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}"
ItemTemplate="{TemplateBinding ItemTemplate}"
Margin="{DynamicResource MenuFlyoutScrollerMargin}"
Grid.IsSharedSizeScope="True" />
</ScrollViewer>
</Border>
</Popup>
</Panel>
</Border>
</ControlTemplate>
</Setter>
</Style>
<Style Selector="MenuItem">
<!-- Narrow padding should be used for mouse input, when non-narrow one should be used for touch input in future. -->
<Setter Property="Padding" Value="{DynamicResource MenuFlyoutItemThemePaddingNarrow}" />
</Style>
<Style Selector="Menu > MenuItem">
<!-- Custom padding for Menu > MenuItem -->
<Setter Property="Padding" Value="{DynamicResource MenuBarItemPadding}" />
</Style>
<Style Selector="MenuItem /template/ ContentPresenter#PART_IconPresenter">
<Setter Property="Width" Value="16" />
<Setter Property="Height" Value="16" />
<Setter Property="IsVisible" Value="False" />
</Style>
<Style Selector="MenuItem:icon /template/ ContentPresenter#PART_IconPresenter">
<Setter Property="IsVisible" Value="True" />
</Style>
<Style Selector="MenuItem /template/ TextBlock#PART_InputGestureText">
<Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForeground}" />
</Style>
<Style Selector="MenuItem /template/ Path#PART_ChevronPath">
<Setter Property="Fill" Value="{DynamicResource MenuFlyoutSubItemChevron}" />
</Style>
<Style Selector="MenuItem:selected /template/ Border#PART_LayoutRoot"> <Style Selector="^:icon /template/ Viewbox#PART_IconPresenter">
<Setter Property="Background" Value="{DynamicResource MenuFlyoutItemBackgroundPointerOver}" /> <Setter Property="IsVisible" Value="True" />
</Style> </Style>
<Style Selector="MenuItem:selected /template/ ContentPresenter#PART_HeaderPresenter">
<Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemForegroundPointerOver}" />
</Style>
<Style Selector="MenuItem:selected /template/ TextBlock#PART_InputGestureText">
<Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForegroundPointerOver}" />
</Style>
<Style Selector="MenuItem:selected /template/ Path#PART_ChevronPath">
<Setter Property="Fill" Value="{DynamicResource MenuFlyoutSubItemChevronPointerOver}" />
</Style>
<!-- Listen for PART_LayoutRoot:pointerover, so it will not be triggered when subitem is pressed --> <Style Selector="^:selected">
<Style Selector="MenuItem:pressed /template/ Border#PART_LayoutRoot:pointerover"> <Style Selector="^ /template/ Border#PART_LayoutRoot">
<Setter Property="Background" Value="{DynamicResource MenuFlyoutItemBackgroundPressed}" /> <Setter Property="Background" Value="{DynamicResource MenuFlyoutItemBackgroundPointerOver}" />
</Style> </Style>
<Style Selector="MenuItem:pressed /template/ Border#PART_LayoutRoot:pointerover ContentPresenter#PART_HeaderPresenter"> <Style Selector="^ /template/ ContentPresenter#PART_HeaderPresenter">
<Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemForegroundPressed}" /> <Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemForegroundPointerOver}" />
</Style> </Style>
<Style Selector="MenuItem:pressed /template/ Border#PART_LayoutRoot:pointerover TextBlock#PART_InputGestureText"> <Style Selector="^ /template/ TextBlock#PART_InputGestureText">
<Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForegroundPressed}" /> <Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForegroundPointerOver}" />
</Style> </Style>
<Style Selector="MenuItem:pressed /template/ Border#PART_LayoutRoot:pointerover Path#PART_ChevronPath"> <Style Selector="^ /template/ Path#PART_ChevronPath">
<Setter Property="Fill" Value="{DynamicResource MenuFlyoutSubItemChevronPressed}" /> <Setter Property="Fill" Value="{DynamicResource MenuFlyoutSubItemChevronPointerOver}" />
</Style> </Style>
</Style>
<Style Selector="MenuItem:disabled /template/ Border#PART_LayoutRoot"> <!-- Listen for PART_LayoutRoot:pointerover, so it will not be triggered when subitem is pressed -->
<Setter Property="Background" Value="{DynamicResource MenuFlyoutItemBackgroundDisabled}" /> <Style Selector="^:pressed /template/ Border#PART_LayoutRoot:pointerover">
</Style> <Setter Property="Background" Value="{DynamicResource MenuFlyoutItemBackgroundPressed}" />
<Style Selector="MenuItem:disabled /template/ ContentPresenter#PART_HeaderPresenter"> <Style Selector="^ ContentPresenter#PART_HeaderPresenter">
<Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemForegroundDisabled}" /> <Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemForegroundPressed}" />
</Style> </Style>
<Style Selector="MenuItem:disabled /template/ TextBlock#PART_InputGestureText"> <Style Selector="^ TextBlock#PART_InputGestureText">
<Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForegroundDisabled}" /> <Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForegroundPressed}" />
</Style> </Style>
<Style Selector="MenuItem:disabled /template/ Path#PART_ChevronPath"> <Style Selector="^ Path#PART_ChevronPath">
<Setter Property="Fill" Value="{DynamicResource MenuFlyoutSubItemChevronDisabled}" /> <Setter Property="Fill" Value="{DynamicResource MenuFlyoutSubItemChevronPressed}" />
</Style> </Style>
</Style>
<Style Selector="MenuItem:open /template/ Path#PART_ChevronPath"> <Style Selector="^:disabled">
<Setter Property="Fill" Value="{DynamicResource MenuFlyoutSubItemChevronSubMenuOpened}" /> <Style Selector="^ /template/ Border#PART_LayoutRoot">
</Style> <Setter Property="Background" Value="{DynamicResource MenuFlyoutItemBackgroundDisabled}" />
</Style>
<Style Selector="^ /template/ ContentPresenter#PART_HeaderPresenter">
<Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemForegroundDisabled}" />
</Style>
<Style Selector="^ /template/ TextBlock#PART_InputGestureText">
<Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForegroundDisabled}" />
</Style>
<Style Selector="^ /template/ Path#PART_ChevronPath">
<Setter Property="Fill" Value="{DynamicResource MenuFlyoutSubItemChevronDisabled}" />
</Style>
</Style>
<Style Selector="MenuItem:empty /template/ Path#PART_ChevronPath"> <Style Selector="^:open /template/ Path#PART_ChevronPath">
<Setter Property="IsVisible" Value="False" /> <Setter Property="Fill" Value="{DynamicResource MenuFlyoutSubItemChevronSubMenuOpened}" />
</Style> </Style>
<Style Selector="MenuItem:separator"> <Style Selector="^:empty /template/ Path#PART_ChevronPath">
<Setter Property="Template"> <Setter Property="IsVisible" Value="False" />
<ControlTemplate> </Style>
<Separator />
</ControlTemplate>
</Setter>
</Style>
<Style Selector="MenuItem > Separator, ContextMenu > Separator"> <Style Selector="^:separator">
<Setter Property="Background" Value="{DynamicResource SystemControlForegroundBaseMediumLowBrush}" /> <Setter Property="Template">
<Setter Property="HorizontalAlignment" Value="Stretch" /> <ControlTemplate>
<Setter Property="Margin" Value="{DynamicResource MenuFlyoutSeparatorThemePadding}" /> <Separator/>
<Setter Property="Height" Value="{DynamicResource MenuFlyoutSeparatorThemeHeight}" /> </ControlTemplate>
</Style> </Setter>
</Styles> </Style>
</ControlTheme>
</ResourceDictionary>

98
src/Avalonia.Themes.Fluent/Controls/MenuScrollViewer.xaml

@ -0,0 +1,98 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls">
<Design.PreviewWith>
<ScrollViewer Theme="{DynamicResource FluentMenuScrollViewer}" Width="200" Height="200">
<StackPanel Spacing="20">
<TextBlock>Item 1</TextBlock>
<TextBlock>Item 2</TextBlock>
<TextBlock>Item 3</TextBlock>
<TextBlock>Item 4</TextBlock>
<TextBlock>Item 5</TextBlock>
<TextBlock>Item 6</TextBlock>
<TextBlock>Item 7</TextBlock>
<TextBlock>Item 8</TextBlock>
<TextBlock>Item 9</TextBlock>
</StackPanel>
</ScrollViewer>
</Design.PreviewWith>
<ControlTheme x:Key="FluentMenuScrollViewer" TargetType="ScrollViewer">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
<ControlTemplate>
<DockPanel>
<RepeatButton DockPanel.Dock="Top"
BorderThickness="0"
Background="Transparent"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Center"
RenderTransform="{x:Null}"
Command="{Binding LineUp, RelativeSource={RelativeSource TemplatedParent}}">
<RepeatButton.IsVisible>
<MultiBinding Converter="{x:Static converters:MenuScrollingVisibilityConverter.Instance}"
ConverterParameter="0">
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="VerticalScrollBarVisibility" />
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Offset.Y" />
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Extent.Height" />
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Viewport.Height" />
</MultiBinding>
</RepeatButton.IsVisible>
<Viewbox Width="{DynamicResource ScrollBarButtonArrowIconFontSize}"
Height="{DynamicResource ScrollBarButtonArrowIconFontSize}">
<Path VerticalAlignment="Center"
HorizontalAlignment="Center"
Data="M 19.091797 14.970703 L 10 5.888672 L 0.908203 14.970703 L 0.029297 14.091797 L 10 4.111328 L 19.970703 14.091797 Z"
Fill="{DynamicResource ScrollBarButtonArrowForeground}"
Width="20"
Height="20" />
</Viewbox>
</RepeatButton>
<RepeatButton DockPanel.Dock="Bottom"
BorderThickness="0"
Background="Transparent"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Center"
RenderTransform="{x:Null}"
Command="{Binding LineDown, RelativeSource={RelativeSource TemplatedParent}}">
<RepeatButton.IsVisible>
<MultiBinding Converter="{x:Static converters:MenuScrollingVisibilityConverter.Instance}"
ConverterParameter="100">
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="VerticalScrollBarVisibility" />
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Offset.Y" />
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Extent.Height" />
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Viewport.Height" />
</MultiBinding>
</RepeatButton.IsVisible>
<Viewbox Width="{DynamicResource ScrollBarButtonArrowIconFontSize}"
Height="{DynamicResource ScrollBarButtonArrowIconFontSize}">
<Path VerticalAlignment="Center"
HorizontalAlignment="Center"
Data="M 18.935547 4.560547 L 19.814453 5.439453 L 10 15.253906 L 0.185547 5.439453 L 1.064453 4.560547 L 10 13.496094 Z"
Fill="{DynamicResource ScrollBarButtonArrowForeground}"
Width="20"
Height="20" />
</Viewbox>
</RepeatButton>
<ScrollContentPresenter Name="PART_ContentPresenter"
CanHorizontallyScroll="{TemplateBinding CanHorizontallyScroll}"
CanVerticallyScroll="{TemplateBinding CanVerticallyScroll}"
Content="{TemplateBinding Content}"
Extent="{TemplateBinding Extent, Mode=TwoWay}"
Margin="{TemplateBinding Padding}"
Offset="{TemplateBinding Offset, Mode=TwoWay}"
Viewport="{TemplateBinding Viewport, Mode=TwoWay}">
<ScrollContentPresenter.GestureRecognizers>
<ScrollGestureRecognizer CanHorizontallyScroll="{TemplateBinding CanHorizontallyScroll}"
CanVerticallyScroll="{TemplateBinding CanVerticallyScroll}" />
</ScrollContentPresenter.GestureRecognizers>
</ScrollContentPresenter>
</DockPanel>
</ControlTemplate>
</Setter>
<Style Selector="^ /template/ RepeatButton:pointerover > Viewbox > Path">
<Setter Property="Fill" Value="{DynamicResource ScrollBarButtonArrowForegroundPointerOver}" />
</Style>
</ControlTheme>
</ResourceDictionary>

61
src/Avalonia.Themes.Fluent/Controls/NativeMenuBar.xaml

@ -1,31 +1,30 @@
<Style xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Avalonia.Themes.Fluent" xmlns:local="clr-namespace:Avalonia.Themes.Fluent"
x:CompileBindings="True" x:CompileBindings="True">
Selector="NativeMenuBar"> <local:InverseBooleanValueConverter x:Key="AvaloniaThemesFluentNativeMenuBarInverseBooleanValueConverter" Default="True"/>
<Style.Resources> <local:IBitmapToImageConverter x:Key="AvaloniaThemesFluentNativeMenuBarIBitmapToImageConverter"/>
<local:InverseBooleanValueConverter x:Key="AvaloniaThemesFluentNativeMenuBarInverseBooleanValueConverter" Default="True"/> <ControlTheme x:Key="{x:Type NativeMenuBar}" TargetType="NativeMenuBar">
<local:IBitmapToImageConverter x:Key="AvaloniaThemesFluentNativeMenuBarIBitmapToImageConverter"/> <Setter Property="Template">
</Style.Resources> <ControlTemplate>
<Setter Property="Template"> <Menu
<ControlTemplate> IsVisible="{Binding $parent[TopLevel].(NativeMenu.IsNativeMenuExported), Converter={StaticResource AvaloniaThemesFluentNativeMenuBarInverseBooleanValueConverter}}"
<Menu Items="{Binding $parent[TopLevel].(NativeMenu.Menu).Items}">
IsVisible="{Binding $parent[TopLevel].(NativeMenu.IsNativeMenuExported), Converter={StaticResource AvaloniaThemesFluentNativeMenuBarInverseBooleanValueConverter}}" <Menu.Styles>
Items="{Binding $parent[TopLevel].(NativeMenu.Menu).Items}"> <Style x:CompileBindings="False" Selector="MenuItem">
<Menu.Styles> <Setter Property="Header" Value="{Binding Header}"/>
<Style x:CompileBindings="False" Selector="MenuItem"> <Setter Property="IsEnabled" Value="{Binding IsEnabled}"/>
<Setter Property="Header" Value="{Binding Header}"/> <Setter Property="InputGesture" Value="{Binding Gesture}"/>
<Setter Property="IsEnabled" Value="{Binding IsEnabled}"/> <Setter Property="Items" Value="{Binding Menu.Items}"/>
<Setter Property="InputGesture" Value="{Binding Gesture}"/> <Setter Property="Command" Value="{Binding Command}"/>
<Setter Property="Items" Value="{Binding Menu.Items}"/> <Setter Property="CommandParameter" Value="{Binding CommandParameter}"/>
<Setter Property="Command" Value="{Binding Command}"/> <Setter Property="(NativeMenuBar.EnableMenuItemClickForwarding)" Value="True"/>
<Setter Property="CommandParameter" Value="{Binding CommandParameter}"/> <!--NativeMenuItem is IBitmap and MenuItem is Image-->
<Setter Property="(NativeMenuBar.EnableMenuItemClickForwarding)" Value="True"/> <Setter Property="Icon" Value="{Binding Icon , Converter={StaticResource AvaloniaThemesFluentNativeMenuBarIBitmapToImageConverter}}"/>
<!--NativeMenuItem is IBitmap and MenuItem is Image--> </Style>
<Setter Property="Icon" Value="{Binding Icon , Converter={StaticResource AvaloniaThemesFluentNativeMenuBarIBitmapToImageConverter}}"/> </Menu.Styles>
</Style> </Menu>
</Menu.Styles> </ControlTemplate>
</Menu> </Setter>
</ControlTemplate> </ControlTheme>
</Setter> </ResourceDictionary>
</Style>

107
src/Avalonia.Themes.Fluent/Controls/NotificationCard.xaml

@ -1,15 +1,15 @@
<Styles xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith> <Design.PreviewWith>
<Border Padding="0" Background="White"> <Border Padding="0" Background="White">
<NotificationCard Content="Testing" /> <NotificationCard Content="Testing" />
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Style Selector="NotificationCard"> <ControlTheme x:Key="{x:Type NotificationCard}" TargetType="NotificationCard">
<Setter Property="UseLayoutRounding" Value="True"/> <Setter Property="UseLayoutRounding" Value="True"/>
<Setter Property="Width" Value="350"/> <Setter Property="Width" Value="350"/>
<Setter Property="FontSize" Value="14"/> <Setter Property="FontSize" Value="14"/>
<Setter Property="Foreground" Value="White"/> <Setter Property="Foreground" Value="{DynamicResource NotificationCardForegroundBrush}"/>
<Setter Property="RenderTransformOrigin" Value="50%,75%"/> <Setter Property="RenderTransformOrigin" Value="50%,75%"/>
<Setter Property="BorderThickness" Value="0" /> <Setter Property="BorderThickness" Value="0" />
<Setter Property="Background" Value="{DynamicResource NotificationCardBackgroundBrush}" /> <Setter Property="Background" Value="{DynamicResource NotificationCardBackgroundBrush}" />
@ -24,8 +24,8 @@
CornerRadius="{TemplateBinding CornerRadius}" CornerRadius="{TemplateBinding CornerRadius}"
ClipToBounds="True"> ClipToBounds="True">
<DockPanel> <DockPanel>
<Panel x:Name="PART_HeaderBar" Height="4" DockPanel.Dock="Top" /> <Panel x:Name="PART_HeaderBar" Height="4" Background="{DynamicResource NotificationCardProgressBackgroundBrush}" DockPanel.Dock="Top" />
<ContentControl Name="PART_Content" Content="{TemplateBinding Content}" /> <ContentControl Name="PART_Content" MinHeight="64" Content="{TemplateBinding Content}" />
</DockPanel> </DockPanel>
</Border> </Border>
</Border> </Border>
@ -33,7 +33,7 @@
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
<Style.Animations> <ControlTheme.Animations>
<Animation Duration="0:0:0.45" Easing="QuadraticEaseIn" FillMode="Forward"> <Animation Duration="0:0:0.45" Easing="QuadraticEaseIn" FillMode="Forward">
<KeyFrame Cue="0%"> <KeyFrame Cue="0%">
<Setter Property="Opacity" Value="0"/> <Setter Property="Opacity" Value="0"/>
@ -51,56 +51,49 @@
<Setter Property="ScaleTransform.ScaleY" Value="1"/> <Setter Property="ScaleTransform.ScaleY" Value="1"/>
</KeyFrame> </KeyFrame>
</Animation> </Animation>
</Style.Animations> </ControlTheme.Animations>
</Style>
<Style Selector="NotificationCard/template/ ContentControl#PART_Content"> <Style Selector="^[IsClosing=true] /template/ LayoutTransformControl#PART_LayoutTransformControl">
<Setter Property="MinHeight" Value="64" /> <Setter Property="RenderTransformOrigin" Value="50%,0%"/>
</Style> <Style.Animations>
<Animation Duration="0:0:0.75" Easing="QuadraticEaseOut" FillMode="Forward">
<KeyFrame Cue="0%">
<Setter Property="TranslateTransform.X" Value="0"/>
<Setter Property="ScaleTransform.ScaleY" Value="1"/>
</KeyFrame>
<KeyFrame Cue="70%">
<Setter Property="TranslateTransform.X" Value="800"/>
<Setter Property="ScaleTransform.ScaleY" Value="1"/>
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="ScaleTransform.ScaleY" Value="0"/>
<Setter Property="TranslateTransform.X" Value="800"/>
</KeyFrame>
</Animation>
</Style.Animations>
</Style>
<Style Selector="NotificationCard[IsClosing=true] /template/ LayoutTransformControl#PART_LayoutTransformControl"> <Style Selector="^[IsClosing=true]">
<Setter Property="RenderTransformOrigin" Value="50%,0%"/> <Style.Animations>
<Style.Animations> <Animation Duration="0:0:1.25" Easing="QuadraticEaseOut" FillMode="Forward">
<Animation Duration="0:0:0.75" Easing="QuadraticEaseOut" FillMode="Forward"> <KeyFrame Cue="100%">
<KeyFrame Cue="0%"> <Setter Property="IsClosed" Value="True"/>
<Setter Property="TranslateTransform.X" Value="0"/> </KeyFrame>
<Setter Property="ScaleTransform.ScaleY" Value="1"/> </Animation>
</KeyFrame> </Style.Animations>
<KeyFrame Cue="70%"> </Style>
<Setter Property="TranslateTransform.X" Value="800"/>
<Setter Property="ScaleTransform.ScaleY" Value="1"/>
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="ScaleTransform.ScaleY" Value="0"/>
<Setter Property="TranslateTransform.X" Value="800"/>
</KeyFrame>
</Animation>
</Style.Animations>
</Style>
<Style Selector="NotificationCard[IsClosing=true]">
<Style.Animations>
<Animation Duration="0:0:1.25" Easing="QuadraticEaseOut" FillMode="Forward">
<KeyFrame Cue="100%">
<Setter Property="IsClosed" Value="True"/>
</KeyFrame>
</Animation>
</Style.Animations>
</Style>
<Style Selector="NotificationCard /template/ Panel#PART_HeaderBar"> <Style Selector="^:information /template/ Panel#PART_HeaderBar">
<Setter Property="Background" Value="{DynamicResource NotificationCardProgressBackgroundBrush}"/> <Setter Property="Background" Value="{DynamicResource NotificationCardInformationBackgroundBrush}"/>
</Style> </Style>
<Style Selector="NotificationCard:information /template/ Panel#PART_HeaderBar"> <Style Selector="^:success /template/ Panel#PART_HeaderBar">
<Setter Property="Background" Value="{DynamicResource NotificationCardInformationBackgroundBrush}"/> <Setter Property="Background" Value="{DynamicResource NotificationCardSuccessBackgroundBrush}"/>
</Style> </Style>
<Style Selector="NotificationCard:success /template/ Panel#PART_HeaderBar"> <Style Selector="^:warning /template/ Panel#PART_HeaderBar">
<Setter Property="Background" Value="{DynamicResource NotificationCardSuccessBackgroundBrush}"/> <Setter Property="Background" Value="{DynamicResource NotificationCardWarningBackgroundBrush}"/>
</Style> </Style>
<Style Selector="NotificationCard:warning /template/ Panel#PART_HeaderBar"> <Style Selector="^:error /template/ Panel#PART_HeaderBar">
<Setter Property="Background" Value="{DynamicResource NotificationCardWarningBackgroundBrush}"/> <Setter Property="Background" Value="{DynamicResource NotificationCardErrorBackgroundBrush}"/>
</Style> </Style>
<Style Selector="NotificationCard:error /template/ Panel#PART_HeaderBar"> </ControlTheme>
<Setter Property="Background" Value="{DynamicResource NotificationCardErrorBackgroundBrush}"/> </ResourceDictionary>
</Style>
</Styles>

15
src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml

@ -1,17 +1,15 @@
<Styles xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith> <Design.PreviewWith>
<Border Padding="20"> <Border Padding="20">
<StackPanel Spacing="20"> <StackPanel Spacing="20">
<NumericUpDown Minimum="0" <NumericUpDown Minimum="0"
Maximum="10" Maximum="10"
Increment="0.5" Increment="0.5"
Width="150"
Watermark="Enter text" /> Watermark="Enter text" />
<NumericUpDown Minimum="0" <NumericUpDown Minimum="0"
Maximum="10" Maximum="10"
Increment="0.5" Increment="0.5"
Width="150"
VerticalContentAlignment="Center" VerticalContentAlignment="Center"
HorizontalContentAlignment="Center" HorizontalContentAlignment="Center"
ButtonSpinnerLocation="Left" ButtonSpinnerLocation="Left"
@ -20,13 +18,13 @@
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Style Selector="NumericUpDown"> <ControlTheme x:Key="{x:Type NumericUpDown}" TargetType="NumericUpDown">
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" /> <Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" />
<Setter Property="Background" Value="{DynamicResource TextControlBackground}" /> <Setter Property="Background" Value="{DynamicResource TextControlBackground}" />
<Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThickness}" /> <Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThickness}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrush}" />
<Setter Property="MinHeight" Value="{DynamicResource TextControlThemeMinHeight}" /> <Setter Property="MinHeight" Value="{DynamicResource TextControlThemeMinHeight}" />
<Setter Property="MinWidth" Value="{DynamicResource TextControlThemeMinWidth}" /> <Setter Property="MinWidth" Value="{DynamicResource TextControlThemeMinWidth}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="Padding" Value="{DynamicResource TextControlThemePadding}" /> <Setter Property="Padding" Value="{DynamicResource TextControlThemePadding}" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" /> <Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
@ -63,6 +61,5 @@
</ButtonSpinner> </ButtonSpinner>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> </ControlTheme>
</ResourceDictionary>
</Styles>

43
src/Avalonia.Themes.Fluent/Controls/OverlayPopupHost.xaml

@ -1,20 +1,23 @@
<Style xmlns="https://github.com/avaloniaui" Selector="OverlayPopupHost"> <ResourceDictionary xmlns="https://github.com/avaloniaui"
<Setter Property="Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}"/> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}"/> <ControlTheme x:Key="{x:Type OverlayPopupHost}" TargetType="OverlayPopupHost">
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" /> <Setter Property="Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}"/>
<Setter Property="FontWeight" Value="400" /> <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}"/>
<Setter Property="FontStyle" Value="Normal" /> <Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
<Setter Property="Template"> <Setter Property="FontWeight" Value="400" />
<ControlTemplate> <Setter Property="FontStyle" Value="Normal" />
<LayoutTransformControl LayoutTransform="{TemplateBinding Transform}"> <Setter Property="Template">
<VisualLayerManager IsPopup="True"> <ControlTemplate>
<ContentPresenter Name="PART_ContentPresenter" <LayoutTransformControl LayoutTransform="{TemplateBinding Transform}">
Background="{TemplateBinding Background}" <VisualLayerManager IsPopup="True">
ContentTemplate="{TemplateBinding ContentTemplate}" <ContentPresenter Name="PART_ContentPresenter"
Content="{TemplateBinding Content}" Background="{TemplateBinding Background}"
Padding="{TemplateBinding Padding}"/> ContentTemplate="{TemplateBinding ContentTemplate}"
</VisualLayerManager> Content="{TemplateBinding Content}"
</LayoutTransformControl> Padding="{TemplateBinding Padding}"/>
</ControlTemplate> </VisualLayerManager>
</Setter> </LayoutTransformControl>
</Style> </ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>

18
src/Avalonia.Themes.Fluent/Controls/PathIcon.xaml

@ -1,5 +1,5 @@
<Styles xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith> <Design.PreviewWith>
<StackPanel> <StackPanel>
<StackPanel.Resources> <StackPanel.Resources>
@ -8,22 +8,18 @@
<PathIcon Data="{StaticResource settings_regular}" /> <PathIcon Data="{StaticResource settings_regular}" />
</StackPanel> </StackPanel>
</Design.PreviewWith> </Design.PreviewWith>
<Style Selector="PathIcon"> <ControlTheme x:Key="{x:Type PathIcon}" TargetType="PathIcon">
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" />
<Setter Property="Background" Value="Transparent" /> <Setter Property="Background" Value="Transparent" />
<Setter Property="Height" Value="{DynamicResource IconElementThemeHeight}" /> <Setter Property="Height" Value="{DynamicResource IconElementThemeHeight}" />
<Setter Property="Width" Value="{DynamicResource IconElementThemeWidth}" /> <Setter Property="Width" Value="{DynamicResource IconElementThemeWidth}" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Border Background="{TemplateBinding Background}"> <Border Background="{TemplateBinding Background}">
<Viewbox Height="{TemplateBinding Height}" <Viewbox Height="{TemplateBinding Height}" Width="{TemplateBinding Width}">
Width="{TemplateBinding Width}"> <Path Fill="{TemplateBinding Foreground}" Data="{TemplateBinding Data}" Stretch="Uniform" />
<Path Fill="{TemplateBinding Foreground}"
Data="{TemplateBinding Data}"
Stretch="Uniform" />
</Viewbox> </Viewbox>
</Border> </Border>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> </ControlTheme>
</Styles> </ResourceDictionary>

24
src/Avalonia.Themes.Fluent/Controls/PopupRoot.xaml

@ -1,10 +1,10 @@
<Styles xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style Selector="PopupRoot"> <ControlTheme x:Key="{x:Type PopupRoot}" TargetType="PopupRoot">
<Setter Property="Background" Value="{x:Null}"/> <Setter Property="Background" Value="{x:Null}" />
<Setter Property="TransparencyLevelHint" Value="Transparent" /> <Setter Property="TransparencyLevelHint" Value="Transparent" />
<Setter Property="Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}"/> <Setter Property="Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}"/> <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" /> <Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
<Setter Property="FontWeight" Value="400" /> <Setter Property="FontWeight" Value="400" />
<Setter Property="FontStyle" Value="Normal" /> <Setter Property="FontStyle" Value="Normal" />
@ -15,14 +15,14 @@
<Border Name="PART_TransparencyFallback" IsHitTestVisible="False" /> <Border Name="PART_TransparencyFallback" IsHitTestVisible="False" />
<VisualLayerManager IsPopup="True"> <VisualLayerManager IsPopup="True">
<ContentPresenter Name="PART_ContentPresenter" <ContentPresenter Name="PART_ContentPresenter"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}" Content="{TemplateBinding Content}"
Padding="{TemplateBinding Padding}"/> Padding="{TemplateBinding Padding}" />
</VisualLayerManager> </VisualLayerManager>
</Panel> </Panel>
</LayoutTransformControl> </LayoutTransformControl>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> </ControlTheme>
</Styles> </ResourceDictionary>

322
src/Avalonia.Themes.Fluent/Controls/ProgressBar.xaml

@ -1,22 +1,31 @@
<Styles xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls" xmlns:converters="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls"
x:CompileBindings="True"> x:CompileBindings="True">
<Design.PreviewWith> <Design.PreviewWith>
<Border Padding="20"> <Border Padding="20">
<StackPanel Spacing="10"> <StackPanel Orientation="Horizontal" Spacing="10">
<ProgressBar VerticalAlignment="Center" IsIndeterminate="True" /> <StackPanel Spacing="10">
<ProgressBar VerticalAlignment="Center" Value="5" Maximum="10" /> <ProgressBar Value="5" Maximum="10" />
<ProgressBar VerticalAlignment="Center" Value="50" /> <ProgressBar Value="50" />
<ProgressBar VerticalAlignment="Center" Value="50" Minimum="25" Maximum="75" /> <ProgressBar Value="50" Minimum="25" Maximum="75" />
<ProgressBar HorizontalAlignment="Left" IsIndeterminate="True" Orientation="Vertical" /> <ProgressBar IsIndeterminate="True" />
<ProgressBar ShowProgressText="True" Value="50"/>
<ProgressBar ShowProgressText="True"
ProgressTextFormat="\{1\} percent"
Minimum="50"
Maximum="100"
Value="70"/>
</StackPanel>
<ProgressBar IsIndeterminate="True" Orientation="Vertical" />
<ProgressBar ShowProgressText="True" Value="50" Orientation="Vertical"/>
</StackPanel> </StackPanel>
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Style Selector="ProgressBar">
<Style.Resources> <converters:StringFormatConverter x:Key="StringFormatConverter"/>
<converters:StringFormatConverter x:Key="StringFormatConverter"/>
</Style.Resources> <ControlTheme x:Key="{x:Type ProgressBar}" TargetType="ProgressBar">
<Setter Property="Foreground" Value="{DynamicResource SystemControlHighlightAccentBrush}" /> <Setter Property="Foreground" Value="{DynamicResource SystemControlHighlightAccentBrush}" />
<Setter Property="Background" Value="{DynamicResource SystemControlBackgroundBaseLowBrush}" /> <Setter Property="Background" Value="{DynamicResource SystemControlBackgroundBaseLowBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource ProgressBarBorderThemeThickness}" /> <Setter Property="BorderThickness" Value="{DynamicResource ProgressBarBorderThemeThickness}" />
@ -26,17 +35,49 @@
<Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate TargetType="ProgressBar"> <ControlTemplate TargetType="ProgressBar">
<Border x:Name="ProgressBarRoot" ClipToBounds="True" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}"> <Border
<Panel> x:Name="ProgressBarRoot"
<Panel x:Name="DeterminateRoot"> Background="{TemplateBinding Background}"
<Border CornerRadius="{TemplateBinding CornerRadius}" x:Name="PART_Indicator" Margin="{TemplateBinding Padding}" Background="{TemplateBinding Foreground}" /> BorderBrush="{TemplateBinding BorderBrush}"
</Panel> BorderThickness="{TemplateBinding BorderThickness}"
<Panel x:Name="IndeterminateRoot"> ClipToBounds="True"
<Border x:Name="IndeterminateProgressBarIndicator" CornerRadius="{TemplateBinding CornerRadius}" Margin="{TemplateBinding Padding}" Background="{TemplateBinding Foreground}" /> CornerRadius="{TemplateBinding CornerRadius}">
<Border x:Name="IndeterminateProgressBarIndicator2" CornerRadius="{TemplateBinding CornerRadius}" Margin="{TemplateBinding Padding}" Background="{TemplateBinding Foreground}" /> <Panel>
</Panel> <Panel x:Name="DeterminateRoot" Opacity="1">
<LayoutTransformControl x:Name="PART_LayoutTransformControl" HorizontalAlignment="Center" VerticalAlignment="Center" IsVisible="{TemplateBinding ShowProgressText}"> <Panel.Transitions>
<TextBlock Foreground="{DynamicResource SystemControlForegroundBaseHighBrush}"> <Transitions>
<DoubleTransition Property="Opacity" Duration="0:0:0.197" />
</Transitions>
</Panel.Transitions>
<Border
x:Name="PART_Indicator"
Margin="{TemplateBinding Padding}"
Background="{TemplateBinding Foreground}"
CornerRadius="{TemplateBinding CornerRadius}" />
</Panel>
<Panel x:Name="IndeterminateRoot" Opacity="0">
<Panel.Transitions>
<Transitions>
<DoubleTransition Property="Opacity" Duration="0:0:0.197" />
</Transitions>
</Panel.Transitions>
<Border
x:Name="IndeterminateProgressBarIndicator"
Margin="{TemplateBinding Padding}"
Background="{TemplateBinding Foreground}"
CornerRadius="{TemplateBinding CornerRadius}" />
<Border
x:Name="IndeterminateProgressBarIndicator2"
Margin="{TemplateBinding Padding}"
Background="{TemplateBinding Foreground}"
CornerRadius="{TemplateBinding CornerRadius}" />
</Panel>
<LayoutTransformControl
x:Name="PART_LayoutTransformControl"
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsVisible="{TemplateBinding ShowProgressText}">
<TextBlock Foreground="{DynamicResource SystemControlForegroundBaseHighBrush}">
<TextBlock.Text> <TextBlock.Text>
<MultiBinding Converter="{StaticResource StringFormatConverter}"> <MultiBinding Converter="{StaticResource StringFormatConverter}">
<TemplateBinding Property="ProgressTextFormat"/> <TemplateBinding Property="ProgressTextFormat"/>
@ -47,132 +88,111 @@
</MultiBinding> </MultiBinding>
</TextBlock.Text> </TextBlock.Text>
</TextBlock> </TextBlock>
</LayoutTransformControl> </LayoutTransformControl>
</Panel> </Panel>
</Border> </Border>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> <Style Selector="^:horizontal /template/ Border#PART_Indicator">
<Style Selector="ProgressBar:horizontal /template/ Border#PART_Indicator"> <Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="HorizontalAlignment" Value="Left" /> <Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" /> </Style>
</Style> <Style Selector="^:vertical /template/ Border#PART_Indicator">
<Style Selector="ProgressBar:vertical /template/ Border#PART_Indicator"> <Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalAlignment" Value="Stretch" /> <Setter Property="VerticalAlignment" Value="Bottom" />
<Setter Property="VerticalAlignment" Value="Bottom" /> </Style>
</Style> <Style Selector="^:horizontal">
<Style Selector="ProgressBar:horizontal"> <Setter Property="MinWidth" Value="200" />
<Setter Property="MinWidth" Value="200" /> <Setter Property="MinHeight" Value="4" />
<Setter Property="MinHeight" Value="4" /> </Style>
</Style> <Style Selector="^:vertical">
<Style Selector="ProgressBar:vertical"> <Setter Property="MinWidth" Value="4" />
<Setter Property="MinWidth" Value="4" /> <Setter Property="MinHeight" Value="200" />
<Setter Property="MinHeight" Value="200" /> </Style>
</Style> <Style Selector="^:vertical /template/ LayoutTransformControl#PART_LayoutTransformControl">
<Style Selector="ProgressBar:vertical /template/ LayoutTransformControl#PART_LayoutTransformControl"> <Setter Property="LayoutTransform">
<Setter Property="LayoutTransform"> <Setter.Value>
<Setter.Value> <RotateTransform Angle="90" />
<RotateTransform Angle="90" /> </Setter.Value>
</Setter.Value> </Setter>
</Setter> </Style>
</Style> <Style Selector="^:indeterminate /template/ Panel#DeterminateRoot">
<!-- FadeInAnimation mockup--> <Setter Property="Opacity" Value="0" />
<Style Selector="ProgressBar /template/ Panel#DeterminateRoot"> </Style>
<Setter Property="Transitions"> <Style Selector="^:indeterminate /template/ Panel#IndeterminateRoot">
<Transitions> <Setter Property="Opacity" Value="1" />
<DoubleTransition Property="Opacity" Duration="0:0:0.197" /> </Style>
</Transitions> <Style Selector="^:horizontal:indeterminate /template/ Border#IndeterminateProgressBarIndicator">
</Setter> <Style.Animations>
</Style> <Animation IterationCount="Infinite" Duration="0:0:2">
<Style Selector="ProgressBar /template/ Panel#IndeterminateRoot"> <KeyFrame KeySpline="0.4,0,0.6,1" KeyTime="0:0:0">
<Setter Property="Transitions"> <Setter Property="TranslateTransform.X" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationStartPosition}" />
<Transitions> </KeyFrame>
<DoubleTransition Property="Opacity" Duration="0:0:0.197" /> <KeyFrame KeySpline="0.4,0,0.6,1" KeyTime="0:0:1.5">
</Transitions> <Setter Property="TranslateTransform.X" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationEndPosition}" />
</Setter> </KeyFrame>
</Style> <KeyFrame KeySpline="0.4,0,0.6,1" KeyTime="0:0:2">
<Style Selector="ProgressBar /template/ Panel#DeterminateRoot"> <Setter Property="TranslateTransform.X" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationEndPosition}" />
<Setter Property="Opacity" Value="1" /> </KeyFrame>
</Style> </Animation>
<Style Selector="ProgressBar /template/ Panel#IndeterminateRoot"> </Style.Animations>
<Setter Property="Opacity" Value="0" /> </Style>
</Style> <Style Selector="^:horizontal:indeterminate /template/ Border#IndeterminateProgressBarIndicator2">
<Style Selector="ProgressBar:indeterminate /template/ Panel#DeterminateRoot"> <Style.Animations>
<Setter Property="Opacity" Value="0" /> <Animation IterationCount="Infinite" Duration="0:0:2">
</Style> <KeyFrame KeySpline="0.4,0,0.6,1" KeyTime="0:0:0">
<Style Selector="ProgressBar:indeterminate /template/ Panel#IndeterminateRoot"> <Setter Property="TranslateTransform.X" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationStartPosition}" />
<Setter Property="Opacity" Value="1" /> </KeyFrame>
</Style> <KeyFrame KeySpline="0.4,0,0.6,1" KeyTime="0:0:0.75">
<Style Selector="ProgressBar:horizontal:indeterminate /template/ Border#IndeterminateProgressBarIndicator"> <Setter Property="TranslateTransform.X" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationStartPosition}" />
<Style.Animations> </KeyFrame>
<Animation Duration="0:0:2" IterationCount="Infinite"> <KeyFrame KeySpline="0.4,0,0.6,1" KeyTime="0:0:2">
<KeyFrame KeyTime="0:0:0" KeySpline="0.4,0,0.6,1"> <Setter Property="TranslateTransform.X" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationEndPosition}" />
<Setter Property="TranslateTransform.X" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationStartPosition}" /> </KeyFrame>
</KeyFrame> </Animation>
<KeyFrame KeyTime="0:0:1.5" KeySpline="0.4,0,0.6,1"> </Style.Animations>
<Setter Property="TranslateTransform.X" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationEndPosition}" /> </Style>
</KeyFrame> <Style Selector="^:vertical:indeterminate /template/ Border#IndeterminateProgressBarIndicator">
<KeyFrame KeyTime="0:0:2" KeySpline="0.4,0,0.6,1"> <Style.Animations>
<Setter Property="TranslateTransform.X" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationEndPosition}" /> <Animation IterationCount="Infinite" Duration="0:0:2">
</KeyFrame> <KeyFrame KeySpline="0.4,0,0.6,1" KeyTime="0:0:0">
</Animation> <Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationStartPosition}" />
</Style.Animations> </KeyFrame>
</Style> <KeyFrame KeySpline="0.4,0,0.6,1" KeyTime="0:0:1.5">
<Style Selector="ProgressBar:horizontal:indeterminate /template/ Border#IndeterminateProgressBarIndicator2"> <Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationEndPosition}" />
<Style.Animations> </KeyFrame>
<Animation Duration="0:0:2" IterationCount="Infinite"> <KeyFrame KeySpline="0.4,0,0.6,1" KeyTime="0:0:2">
<KeyFrame KeyTime="0:0:0" KeySpline="0.4,0,0.6,1"> <Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationEndPosition}" />
<Setter Property="TranslateTransform.X" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationStartPosition}" /> </KeyFrame>
</KeyFrame> </Animation>
<KeyFrame KeyTime="0:0:0.75" KeySpline="0.4,0,0.6,1"> </Style.Animations>
<Setter Property="TranslateTransform.X" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationStartPosition}" /> </Style>
</KeyFrame> <Style Selector="^:vertical:indeterminate /template/ Border#IndeterminateProgressBarIndicator2">
<KeyFrame KeyTime="0:0:2" KeySpline="0.4,0,0.6,1"> <Style.Animations>
<Setter Property="TranslateTransform.X" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationEndPosition}" /> <Animation IterationCount="Infinite" Duration="0:0:2">
</KeyFrame> <KeyFrame KeySpline="0.4,0,0.6,1" KeyTime="0:0:0">
</Animation> <Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationStartPosition}" />
</Style.Animations> </KeyFrame>
</Style> <KeyFrame KeySpline="0.4,0,0.6,1" KeyTime="0:0:0.75">
<Style Selector="ProgressBar:vertical:indeterminate /template/ Border#IndeterminateProgressBarIndicator"> <Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationStartPosition}" />
<Style.Animations> </KeyFrame>
<Animation Duration="0:0:2" IterationCount="Infinite"> <KeyFrame KeySpline="0.4,0,0.6,1" KeyTime="0:0:2">
<KeyFrame KeyTime="0:0:0" KeySpline="0.4,0,0.6,1"> <Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationEndPosition}" />
<Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationStartPosition}" /> </KeyFrame>
</KeyFrame> </Animation>
<KeyFrame KeyTime="0:0:1.5" KeySpline="0.4,0,0.6,1"> </Style.Animations>
<Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationEndPosition}" /> </Style>
</KeyFrame> <Style Selector="^:horizontal /template/ Border#IndeterminateProgressBarIndicator">
<KeyFrame KeyTime="0:0:2" KeySpline="0.4,0,0.6,1"> <Setter Property="Width" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerWidth}" />
<Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationEndPosition}" /> </Style>
</KeyFrame> <Style Selector="^:horizontal /template/ Border#IndeterminateProgressBarIndicator2">
</Animation> <Setter Property="Width" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2Width}" />
</Style.Animations> </Style>
</Style> <Style Selector="^:vertical /template/ Border#IndeterminateProgressBarIndicator">
<Style Selector="ProgressBar:vertical:indeterminate /template/ Border#IndeterminateProgressBarIndicator2"> <Setter Property="Height" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerWidth}" />
<Style.Animations> </Style>
<Animation Duration="0:0:2" IterationCount="Infinite"> <Style Selector="^:vertical /template/ Border#IndeterminateProgressBarIndicator2">
<KeyFrame KeyTime="0:0:0" KeySpline="0.4,0,0.6,1"> <Setter Property="Height" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2Width}" />
<Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationStartPosition}" /> </Style>
</KeyFrame> </ControlTheme>
<KeyFrame KeyTime="0:0:0.75" KeySpline="0.4,0,0.6,1"> </ResourceDictionary>
<Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationStartPosition}" />
</KeyFrame>
<KeyFrame KeyTime="0:0:2" KeySpline="0.4,0,0.6,1">
<Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationEndPosition}" />
</KeyFrame>
</Animation>
</Style.Animations>
</Style>
<Style Selector="ProgressBar:horizontal /template/ Border#IndeterminateProgressBarIndicator">
<Setter Property="Width" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerWidth}" />
</Style>
<Style Selector="ProgressBar:horizontal /template/ Border#IndeterminateProgressBarIndicator2">
<Setter Property="Width" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2Width}" />
</Style>
<Style Selector="ProgressBar:vertical /template/ Border#IndeterminateProgressBarIndicator">
<Setter Property="Height" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerWidth}" />
</Style>
<Style Selector="ProgressBar:vertical /template/ Border#IndeterminateProgressBarIndicator2">
<Setter Property="Height" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2Width}" />
</Style>
</Styles>

286
src/Avalonia.Themes.Fluent/Controls/RadioButton.xaml

@ -1,4 +1,4 @@
<Styles xmlns="https://github.com/avaloniaui"> <ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith> <Design.PreviewWith>
<Border Padding="20"> <Border Padding="20">
<StackPanel Spacing="10"> <StackPanel Spacing="10">
@ -9,7 +9,8 @@
</StackPanel> </StackPanel>
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Style Selector="RadioButton">
<ControlTheme x:Key="{x:Type RadioButton}" TargetType="RadioButton">
<Setter Property="Background" Value="{DynamicResource RadioButtonBackground}" /> <Setter Property="Background" Value="{DynamicResource RadioButtonBackground}" />
<Setter Property="Foreground" Value="{DynamicResource RadioButtonForeground}" /> <Setter Property="Foreground" Value="{DynamicResource RadioButtonForeground}" />
<Setter Property="BorderBrush" Value="{DynamicResource RadioButtonBorderBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource RadioButtonBorderBrush}" />
@ -18,155 +19,152 @@
<Setter Property="HorizontalAlignment" Value="Left" /> <Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Left" /> <Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate TargetType="RadioButton"> <ControlTemplate TargetType="RadioButton">
<Border Name="RootBorder" <Border
Background="{TemplateBinding Background}" Name="RootBorder"
BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}"
CornerRadius="{TemplateBinding CornerRadius}"> BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<Grid ColumnDefinitions="20,*"> <Grid ColumnDefinitions="20,*">
<Grid VerticalAlignment="Top" <Grid Height="32" VerticalAlignment="Top">
Height="32">
<Ellipse
<Ellipse Name="OuterEllipse" Name="OuterEllipse"
Width="20" Height="20" Width="20"
UseLayoutRounding="False" Height="20"
StrokeThickness="{DynamicResource RadioButtonBorderThemeThickness}" /> Fill="{DynamicResource RadioButtonOuterEllipseFill}"
Stroke="{DynamicResource RadioButtonOuterEllipseStroke}"
<Ellipse Name="CheckOuterEllipse" StrokeThickness="{DynamicResource RadioButtonBorderThemeThickness}"
Width="20" Height="20" UseLayoutRounding="False" />
UseLayoutRounding="False"
StrokeThickness="{DynamicResource RadioButtonBorderThemeThickness}" /> <Ellipse
Name="CheckOuterEllipse"
<Ellipse Name="CheckGlyph" Width="20"
Width="8" Height="8" Height="20"
UseLayoutRounding="False" /> Fill="{DynamicResource RadioButtonOuterEllipseCheckedFill}"
Opacity="0"
Stroke="{DynamicResource RadioButtonOuterEllipseCheckedStroke}"
StrokeThickness="{DynamicResource RadioButtonBorderThemeThickness}"
UseLayoutRounding="False" />
<Ellipse
Name="CheckGlyph"
Width="8"
Height="8"
Fill="{DynamicResource RadioButtonCheckGlyphFill}"
Opacity="0"
Stroke="{DynamicResource RadioButtonCheckGlyphStroke}"
UseLayoutRounding="False" />
</Grid> </Grid>
<ContentPresenter Name="PART_ContentPresenter" <ContentPresenter
Content="{TemplateBinding Content}" Name="PART_ContentPresenter"
ContentTemplate="{TemplateBinding ContentTemplate}" Grid.Column="1"
Foreground="{TemplateBinding Foreground}" Margin="{TemplateBinding Padding}"
Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
RecognizesAccessKey="True" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Content="{TemplateBinding Content}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" ContentTemplate="{TemplateBinding ContentTemplate}"
Grid.Column="1" /> Foreground="{TemplateBinding Foreground}"
RecognizesAccessKey="True" />
</Grid> </Grid>
</Border> </Border>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style>
<!-- PointerOver State -->
<!-- Normal State --> <Style Selector="^:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Style Selector="RadioButton /template/ Ellipse#OuterEllipse"> <Setter Property="Foreground" Value="{DynamicResource RadioButtonForegroundPointerOver}" />
<Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseStroke}" /> </Style>
<Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseFill}" />
</Style> <Style Selector="^:pointerover /template/ Border#RootBorder">
<Setter Property="Background" Value="{DynamicResource RadioButtonBackgroundPointerOver}" />
<Style Selector="RadioButton /template/ Ellipse#CheckOuterEllipse"> <Setter Property="BorderBrush" Value="{DynamicResource RadioButtonBorderBrushPointerOver}" />
<Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseCheckedStroke}" /> </Style>
<Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseCheckedFill}" />
<Setter Property="Opacity" Value="0" /> <Style Selector="^:pointerover /template/ Ellipse#OuterEllipse">
</Style> <Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseStrokePointerOver}" />
<Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseFillPointerOver}" />
<Style Selector="RadioButton /template/ Ellipse#CheckGlyph"> </Style>
<Setter Property="Opacity" Value="0" />
<Setter Property="Stroke" Value="{DynamicResource RadioButtonCheckGlyphStroke}" /> <Style Selector="^:pointerover /template/ Ellipse#CheckOuterEllipse">
<Setter Property="Fill" Value="{DynamicResource RadioButtonCheckGlyphFill}" /> <Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseCheckedStrokePointerOver}" />
</Style> <Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseCheckedFillPointerOver}" />
</Style>
<!-- PointerOver State -->
<Style Selector="RadioButton:pointerover /template/ ContentPresenter#PART_ContentPresenter"> <Style Selector="^:pointerover /template/ Ellipse#CheckGlyph">
<Setter Property="Foreground" Value="{DynamicResource RadioButtonForegroundPointerOver}" /> <Setter Property="Stroke" Value="{DynamicResource RadioButtonCheckGlyphStrokePointerOver}" />
</Style> <Setter Property="Fill" Value="{DynamicResource RadioButtonCheckGlyphFillPointerOver}" />
</Style>
<Style Selector="RadioButton:pointerover /template/ Border#RootBorder">
<Setter Property="Background" Value="{DynamicResource RadioButtonBackgroundPointerOver}" />
<Setter Property="BorderBrush" Value="{DynamicResource RadioButtonBorderBrushPointerOver}" /> <!-- Pressed State -->
</Style> <Style Selector="^:pressed /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource RadioButtonForegroundPressed}" />
<Style Selector="RadioButton:pointerover /template/ Ellipse#OuterEllipse"> </Style>
<Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseStrokePointerOver}" />
<Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseFillPointerOver}" /> <Style Selector="^:pressed /template/ Border#RootBorder">
</Style> <Setter Property="Background" Value="{DynamicResource RadioButtonBackgroundPressed}" />
<Setter Property="BorderBrush" Value="{DynamicResource RadioButtonBorderBrushPressed}" />
<Style Selector="RadioButton:pointerover /template/ Ellipse#CheckOuterEllipse"> </Style>
<Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseCheckedStrokePointerOver}" />
<Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseCheckedFillPointerOver}" /> <Style Selector="^:pressed /template/ Ellipse#OuterEllipse">
</Style> <Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseStrokePressed}" />
<Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseFillPressed}" />
<Style Selector="RadioButton:pointerover /template/ Ellipse#CheckGlyph"> </Style>
<Setter Property="Stroke" Value="{DynamicResource RadioButtonCheckGlyphStrokePointerOver}" />
<Setter Property="Fill" Value="{DynamicResource RadioButtonCheckGlyphFillPointerOver}" /> <Style Selector="^:pressed /template/ Ellipse#CheckOuterEllipse">
</Style> <Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseCheckedStrokePressed}" />
<Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseCheckedFillPressed}" />
</Style>
<!-- Pressed State -->
<Style Selector="RadioButton:pressed /template/ ContentPresenter#PART_ContentPresenter"> <Style Selector="^:pressed /template/ Ellipse#CheckGlyph">
<Setter Property="Foreground" Value="{DynamicResource RadioButtonForegroundPressed}" /> <Setter Property="Stroke" Value="{DynamicResource RadioButtonCheckGlyphStrokePressed}" />
</Style> <Setter Property="Fill" Value="{DynamicResource RadioButtonCheckGlyphFillPressed}" />
</Style>
<Style Selector="RadioButton:pressed /template/ Border#RootBorder">
<Setter Property="Background" Value="{DynamicResource RadioButtonBackgroundPressed}" />
<Setter Property="BorderBrush" Value="{DynamicResource RadioButtonBorderBrushPressed}" /> <!-- Disabled State -->
</Style> <Style Selector="^:disabled /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource RadioButtonForegroundDisabled}" />
<Style Selector="RadioButton:pressed /template/ Ellipse#OuterEllipse"> </Style>
<Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseStrokePressed}" />
<Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseFillPressed}" /> <Style Selector="^:disabled /template/ Border#RootBorder">
</Style> <Setter Property="Background" Value="{DynamicResource RadioButtonBackgroundDisabled}" />
<Setter Property="BorderBrush" Value="{DynamicResource RadioButtonBorderBrushDisabled}" />
<Style Selector="RadioButton:pressed /template/ Ellipse#CheckOuterEllipse"> </Style>
<Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseCheckedStrokePressed}" />
<Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseCheckedFillPressed}" /> <Style Selector="^:disabled /template/ Ellipse#OuterEllipse">
</Style> <Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseStrokeDisabled}" />
<Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseFillDisabled}" />
<Style Selector="RadioButton:pressed /template/ Ellipse#CheckGlyph"> </Style>
<Setter Property="Stroke" Value="{DynamicResource RadioButtonCheckGlyphStrokePressed}" />
<Setter Property="Fill" Value="{DynamicResource RadioButtonCheckGlyphFillPressed}" /> <Style Selector="^:disabled /template/ Ellipse#CheckOuterEllipse">
</Style> <Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseCheckedStrokeDisabled}" />
<Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseCheckedFillDisabled}" />
</Style>
<!-- Disabled State -->
<Style Selector="RadioButton:disabled /template/ ContentPresenter#PART_ContentPresenter"> <Style Selector="^:disabled /template/ Ellipse#CheckGlyph">
<Setter Property="Foreground" Value="{DynamicResource RadioButtonForegroundDisabled}" /> <Setter Property="Stroke" Value="{DynamicResource RadioButtonCheckGlyphFillDisabled}" />
</Style> <Setter Property="Fill" Value="{DynamicResource RadioButtonCheckGlyphStrokeDisabled}" />
</Style>
<Style Selector="RadioButton:disabled /template/ Border#RootBorder">
<Setter Property="Background" Value="{DynamicResource RadioButtonBackgroundDisabled}" />
<Setter Property="BorderBrush" Value="{DynamicResource RadioButtonBorderBrushDisabled}" /> <!-- Checked State -->
</Style> <Style Selector="^:checked /template/ Ellipse#CheckGlyph">
<Setter Property="Opacity" Value="1" />
<Style Selector="RadioButton:disabled /template/ Ellipse#OuterEllipse"> </Style>
<Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseStrokeDisabled}" />
<Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseFillDisabled}" /> <Style Selector="^:checked /template/ Ellipse#OuterEllipse">
</Style> <Setter Property="Opacity" Value="0" />
</Style>
<Style Selector="RadioButton:disabled /template/ Ellipse#CheckOuterEllipse">
<Setter Property="Stroke" Value="{DynamicResource RadioButtonOuterEllipseCheckedStrokeDisabled}" /> <Style Selector="^:checked /template/ Ellipse#CheckOuterEllipse">
<Setter Property="Fill" Value="{DynamicResource RadioButtonOuterEllipseCheckedFillDisabled}" /> <Setter Property="Opacity" Value="1" />
</Style> </Style>
</ControlTheme>
<Style Selector="RadioButton:disabled /template/ Ellipse#CheckGlyph"> </ResourceDictionary>
<Setter Property="Stroke" Value="{DynamicResource RadioButtonCheckGlyphFillDisabled}" />
<Setter Property="Fill" Value="{DynamicResource RadioButtonCheckGlyphStrokeDisabled}" />
</Style>
<!-- Checked State -->
<Style Selector="RadioButton:checked /template/ Ellipse#CheckGlyph">
<Setter Property="Opacity" Value="1" />
</Style>
<Style Selector="RadioButton:checked /template/ Ellipse#OuterEllipse">
<Setter Property="Opacity" Value="0" />
</Style>
<Style Selector="RadioButton:checked /template/ Ellipse#CheckOuterEllipse">
<Setter Property="Opacity" Value="1" />
</Style>
</Styles>

59
src/Avalonia.Themes.Fluent/Controls/RepeatButton.xaml

@ -1,28 +1,29 @@
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith> <Design.PreviewWith>
<Border Padding="20"> <Border Padding="20">
<StackPanel Spacing="20"> <StackPanel Spacing="20">
<RepeatButton Content="Click Me!" /> <RepeatButton Content="Click Me!" />
<RepeatButton Content="Disabled" IsEnabled="False" />
<RepeatButton Content="Rounded" CornerRadius="16"/>
</StackPanel> </StackPanel>
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Styles.Resources>
<Thickness x:Key="ButtonPadding">8,5,8,6</Thickness> <Thickness x:Key="ButtonPadding">8,5,8,6</Thickness>
</Styles.Resources>
<Style Selector="RepeatButton"> <ControlTheme x:Key="{x:Type RepeatButton}" TargetType="RepeatButton">
<Setter Property="Background" Value="{DynamicResource RepeatButtonBackground}" /> <Setter Property="Background" Value="{DynamicResource RepeatButtonBackground}" />
<!--<Setter Property="BackgroundSizing" Value="OuterBorderEdge" />-->
<Setter Property="Foreground" Value="{DynamicResource RepeatButtonForeground}" /> <Setter Property="Foreground" Value="{DynamicResource RepeatButtonForeground}" />
<Setter Property="BorderBrush" Value="{DynamicResource RepeatButtonBorderBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource RepeatButtonBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource ButtonBorderThemeThickness}" /> <Setter Property="BorderThickness" Value="{DynamicResource ButtonBorderThemeThickness}" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" /> <Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="Padding" Value="{StaticResource ButtonPadding}" /> <Setter Property="Padding" Value="{StaticResource ButtonPadding}" />
<Setter Property="HorizontalAlignment" Value="Left" /> <Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="FontWeight" Value="Normal" /> <Setter Property="FontWeight" Value="Normal" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<!--<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}" /> <Setter Property="RenderTransform" Value="none" />
<Setter Property="FocusVisualMargin" Value="-3" />-->
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<ContentPresenter x:Name="PART_ContentPresenter" <ContentPresenter x:Name="PART_ContentPresenter"
@ -37,27 +38,27 @@
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" /> VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style>
<Style Selector="RepeatButton /template/ ContentPresenter#PART_ContentPresenter"> <Style Selector="^:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" /> <Setter Property="Background" Value="{DynamicResource RepeatButtonBackgroundPointerOver}" />
</Style> <Setter Property="BorderBrush" Value="{DynamicResource RepeatButtonBorderBrushPointerOver}" />
<Setter Property="Foreground" Value="{DynamicResource RepeatButtonForegroundPointerOver}" />
</Style>
<Style Selector="RepeatButton:pointerover /template/ ContentPresenter#PART_ContentPresenter"> <Style Selector="^:pressed">
<Setter Property="Background" Value="{DynamicResource RepeatButtonBackgroundPointerOver}" /> <Setter Property="RenderTransform" Value="scale(0.98)" />
<Setter Property="BorderBrush" Value="{DynamicResource RepeatButtonBorderBrushPointerOver}" /> </Style>
<Setter Property="Foreground" Value="{DynamicResource RepeatButtonForegroundPointerOver}" />
</Style>
<Style Selector="RepeatButton:pressed /template/ ContentPresenter#PART_ContentPresenter"> <Style Selector="^:pressed /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource RepeatButtonBackgroundPressed}" /> <Setter Property="Background" Value="{DynamicResource RepeatButtonBackgroundPressed}" />
<Setter Property="BorderBrush" Value="{DynamicResource RepeatButtonBorderBrushPressed}" /> <Setter Property="BorderBrush" Value="{DynamicResource RepeatButtonBorderBrushPressed}" />
<Setter Property="Foreground" Value="{DynamicResource RepeatButtonForegroundPressed}" /> <Setter Property="Foreground" Value="{DynamicResource RepeatButtonForegroundPressed}" />
</Style> </Style>
<Style Selector="RepeatButton:disabled /template/ ContentPresenter#PART_ContentPresenter"> <Style Selector="^:disabled /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource RepeatButtonBackgroundDisabled}" /> <Setter Property="Background" Value="{DynamicResource RepeatButtonBackgroundDisabled}" />
<Setter Property="BorderBrush" Value="{DynamicResource RepeatButtonBorderBrushDisabled}" /> <Setter Property="BorderBrush" Value="{DynamicResource RepeatButtonBorderBrushDisabled}" />
<Setter Property="Foreground" Value="{DynamicResource RepeatButtonForegroundDisabled}" /> <Setter Property="Foreground" Value="{DynamicResource RepeatButtonForegroundDisabled}" />
</Style> </Style>
</Styles> </ControlTheme>
</ResourceDictionary>

521
src/Avalonia.Themes.Fluent/Controls/ScrollBar.xaml

@ -1,302 +1,283 @@
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style Selector="ScrollBar"> <Design.PreviewWith>
<Setter Property="MinWidth" Value="{DynamicResource ScrollBarSize}" /> <Border Padding="20">
<Setter Property="MinHeight" Value="{DynamicResource ScrollBarSize}" /> <StackPanel Orientation="Horizontal" Spacing="20">
<Setter Property="Background" Value="{DynamicResource ScrollBarBackground}" /> <StackPanel Spacing="20">
<Setter Property="Foreground" Value="{DynamicResource ScrollBarForeground}" /> <ScrollBar Orientation="Horizontal" AllowAutoHide="False" VerticalAlignment="Center" Width="100"/>
<Setter Property="BorderBrush" Value="{DynamicResource ScrollBarBorderBrush}" /> <ScrollBar Orientation="Horizontal" AllowAutoHide="False" VerticalAlignment="Center" Width="100" IsEnabled="False"/>
</Style> <ScrollBar Orientation="Horizontal" AllowAutoHide="True" VerticalAlignment="Center" Width="100"/>
<ScrollBar Orientation="Horizontal" AllowAutoHide="True" VerticalAlignment="Center" Width="100" IsEnabled="False"/>
<Style Selector="ScrollBar:vertical"> </StackPanel>
<Setter Property="Template"> <ScrollBar Orientation="Vertical" AllowAutoHide="False" HorizontalAlignment="Center" Height="100"/>
<ControlTemplate> <ScrollBar Orientation="Vertical" AllowAutoHide="False" HorizontalAlignment="Center" Height="100" IsEnabled="False"/>
<Grid x:Name="Root"> <ScrollBar Orientation="Vertical" AllowAutoHide="True" HorizontalAlignment="Center" Height="100"/>
<ScrollBar Orientation="Vertical" AllowAutoHide="True" HorizontalAlignment="Center" Height="100" IsEnabled="False"/>
<Border x:Name="VerticalRoot" </StackPanel>
Background="{TemplateBinding Background}" </Border>
BorderBrush="{TemplateBinding BorderBrush}"> </Design.PreviewWith>
<Grid RowDefinitions="Auto,*,Auto">
<ControlTheme x:Key="FluentScrollBarThumb" TargetType="Thumb">
<Rectangle x:Name="TrackRect" Grid.RowSpan="3" Margin="0" /> <Setter Property="Background" Value="{DynamicResource ScrollBarPanningThumbBackground}"/>
<RepeatButton Name="PART_LineUpButton"
HorizontalAlignment="Center"
Classes="line up"
Grid.Row="0"
Focusable="False"
MinWidth="{DynamicResource ScrollBarSize}"
Height="{DynamicResource ScrollBarSize}" />
<Track Grid.Row="1"
Minimum="{TemplateBinding Minimum}"
Maximum="{TemplateBinding Maximum}"
Value="{TemplateBinding Value, Mode=TwoWay}"
ViewportSize="{TemplateBinding ViewportSize}"
Orientation="{TemplateBinding Orientation}"
IsDirectionReversed="True">
<Track.DecreaseButton>
<RepeatButton Name="PART_PageUpButton"
Classes="largeIncrease"
Focusable="False" />
</Track.DecreaseButton>
<Track.IncreaseButton>
<RepeatButton Name="PART_PageDownButton"
Classes="largeIncrease"
Focusable="False" />
</Track.IncreaseButton>
<Thumb Classes="thumb"
Opacity="1"
Width="{DynamicResource ScrollBarSize}"
MinHeight="{DynamicResource ScrollBarSize}"
RenderTransformOrigin="100%,50%" />
</Track>
<RepeatButton Name="PART_LineDownButton"
HorizontalAlignment="Center"
Classes="line down"
Grid.Row="2"
Focusable="False"
MinWidth="{DynamicResource ScrollBarSize}"
Height="{DynamicResource ScrollBarSize}" />
</Grid>
</Border>
</Grid>
</ControlTemplate>
</Setter>
</Style>
<Style Selector="ScrollBar:horizontal">
<Setter Property="Template">
<ControlTemplate>
<Grid x:Name="Root">
<Border x:Name="HorizontalRoot"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}">
<Grid ColumnDefinitions="Auto,*,Auto">
<Rectangle x:Name="TrackRect" Grid.ColumnSpan="3" Margin="0" />
<RepeatButton Name="PART_LineUpButton"
VerticalAlignment="Center"
Classes="line up"
Grid.Column="0"
Focusable="False"
MinHeight="{DynamicResource ScrollBarSize}"
Width="{DynamicResource ScrollBarSize}" />
<Track Grid.Column="1"
Minimum="{TemplateBinding Minimum}"
Maximum="{TemplateBinding Maximum}"
Value="{TemplateBinding Value, Mode=TwoWay}"
ViewportSize="{TemplateBinding ViewportSize}"
Orientation="{TemplateBinding Orientation}">
<Track.DecreaseButton>
<RepeatButton Name="PART_PageUpButton"
Classes="largeIncrease"
Focusable="False" />
</Track.DecreaseButton>
<Track.IncreaseButton>
<RepeatButton Name="PART_PageDownButton"
Classes="largeIncrease"
Focusable="False" />
</Track.IncreaseButton>
<Thumb Classes="thumb"
Opacity="1"
Height="{DynamicResource ScrollBarSize}"
MinWidth="{DynamicResource ScrollBarSize}"
RenderTransformOrigin="50%,100%" />
</Track>
<RepeatButton Name="PART_LineDownButton"
VerticalAlignment="Center"
Classes="line down"
Grid.Column="2"
Focusable="False"
MinHeight="{DynamicResource ScrollBarSize}"
Width="{DynamicResource ScrollBarSize}" />
</Grid>
</Border>
</Grid>
</ControlTemplate>
</Setter>
</Style>
<Style Selector="ScrollBar[IsExpanded=true] /template/ Grid#Root">
<Setter Property="Background" Value="{DynamicResource ScrollBarBackgroundPointerOver}" />
</Style>
<Style Selector="ScrollBar /template/ Thumb.thumb">
<Setter Property="Background" Value="{DynamicResource ScrollBarPanningThumbBackground}" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate> <ControlTemplate>
<Border x:Name="ThumbVisual" Background="{TemplateBinding Background}" /> <Border Background="{TemplateBinding Background}"
CornerRadius="{TemplateBinding CornerRadius}"/>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>
</Setter> </Setter>
<Setter Property="Transitions"> <Setter Property="Transitions">
<Transitions> <Transitions>
<CornerRadiusTransition Property="CornerRadius" Duration="0:0:0.1" />
<TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.1" /> <TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.1" />
</Transitions> </Transitions>
</Setter> </Setter>
</Style>
<Style Selector="ScrollBar:vertical /template/ Thumb.thumb"> <Style Selector="^:pointerover /template/ Border">
<Setter Property="RenderTransform" Value="{DynamicResource VerticalSmallScrollThumbScaleTransform}" /> <Setter Property="Background" Value="{DynamicResource ScrollBarThumbFillPointerOver}" />
</Style> </Style>
<Style Selector="^:pressed /template/ Border">
<Style Selector="ScrollBar:horizontal /template/ Thumb.thumb"> <Setter Property="Background" Value="{DynamicResource ScrollBarThumbFillPressed}" />
<Setter Property="RenderTransform" Value="{DynamicResource HorizontalSmallScrollThumbScaleTransform}" /> </Style>
</Style> <Style Selector="^:disabled /template/ Border">
<Setter Property="Background" Value="{DynamicResource ScrollBarThumbFillDisabled}" />
<Style Selector="ScrollBar[IsExpanded=true] /template/ Thumb.thumb"> </Style>
<Setter Property="RenderTransform" Value="none" /> </ControlTheme>
<Setter Property="Background" Value="{DynamicResource ScrollBarThumbBackgroundColor}" />
</Style> <ControlTheme x:Key="FluentScrollBarPageButton" TargetType="RepeatButton">
<Setter Property="Background" Value="Transparent" />
<Style Selector="ScrollBar /template/ Thumb.thumb /template/ Border#ThumbVisual"> <Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" /> <Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Transitions"> <Setter Property="Opacity" Value="0" />
<Transitions> <Setter Property="Template">
<CornerRadiusTransition Property="CornerRadius" Duration="0:0:0.1" /> <ControlTemplate>
</Transitions> <Border Background="{TemplateBinding Background}" />
</ControlTemplate>
</Setter> </Setter>
</Style> </ControlTheme>
<Style Selector="ScrollBar[IsExpanded=true] /template/ Thumb.thumb /template/ Border#ThumbVisual">
<Setter Property="CornerRadius" Value="0" />
</Style>
<Style Selector="ScrollBar /template/ Thumb.thumb:pointerover">
<Setter Property="Background" Value="{DynamicResource ScrollBarThumbFillPointerOver}" />
</Style>
<Style Selector="ScrollBar /template/ Thumb.thumb:pressed"> <ControlTheme x:Key="FluentScrollBarLineButton" TargetType="RepeatButton">
<Setter Property="Background" Value="{DynamicResource ScrollBarThumbFillPressed}" /> <Setter Property="Opacity" Value="0" />
</Style> <Setter Property="TextElement.Foreground" Value="{DynamicResource ScrollBarButtonArrowForeground}"/>
<Style Selector="ScrollBar /template/ Thumb.thumb:disabled">
<Setter Property="Background" Value="{DynamicResource ScrollBarThumbFillDisabled}" />
</Style>
<Style Selector="ScrollBar /template/ RepeatButton.line">
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Border x:Name="Root"> <ContentPresenter Background="{DynamicResource ScrollBarButtonBackground}"
<Viewbox Width="{DynamicResource ScrollBarButtonArrowIconFontSize}" BorderBrush="{DynamicResource ScrollBarButtonBorderBrush}"
Height="{DynamicResource ScrollBarButtonArrowIconFontSize}"> Content="{TemplateBinding Content}"/>
<Path x:Name="Arrow"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Width="20" Height="20" />
</Viewbox>
</Border>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
<Setter Property="Opacity" Value="0" />
<Setter Property="Transitions"> <Setter Property="Transitions">
<Transitions> <Transitions>
<DoubleTransition Property="Opacity" Duration="0:0:0.1" /> <DoubleTransition Property="Opacity" Duration="0:0:0.1" />
</Transitions> </Transitions>
</Setter> </Setter>
</Style>
<Style Selector="ScrollBar /template/ RepeatButton.line /template/ Border#Root" >
<Setter Property="Background" Value="{DynamicResource ScrollBarButtonBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource ScrollBarButtonBorderBrush}" />
</Style>
<Style Selector="ScrollBar /template/ RepeatButton.line:pointerover /template/ Border#Root" > <Style Selector="^:pointerover">
<Setter Property="Background" Value="{DynamicResource ScrollBarButtonBackgroundPointerOver}" /> <Setter Property="TextElement.Foreground" Value="{DynamicResource ScrollBarButtonArrowForegroundPointerOver}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ScrollBarButtonBorderBrushPointerOver}" />
</Style>
<Style Selector="ScrollBar /template/ RepeatButton.line:pressed /template/ Border#Root" > <Style Selector="^ /template/ ContentPresenter" >
<Setter Property="Background" Value="{DynamicResource ScrollBarButtonBackgroundPressed}" /> <Setter Property="Background" Value="{DynamicResource ScrollBarButtonBackgroundPointerOver}" />
<Setter Property="BorderBrush" Value="{DynamicResource ScrollBarButtonBorderBrushPressed}" /> <Setter Property="BorderBrush" Value="{DynamicResource ScrollBarButtonBorderBrushPointerOver}" />
</Style> </Style>
</Style>
<Style Selector="ScrollBar /template/ RepeatButton.line:disabled /template/ Border#Root" > <Style Selector="^:pressed">
<Setter Property="Background" Value="{DynamicResource ScrollBarButtonBackgroundPressed}" /> <Setter Property="TextElement.Foreground" Value="{DynamicResource ScrollBarButtonArrowForegroundPressed}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ScrollBarButtonBorderBrushDisabled}" />
</Style>
<Style Selector="ScrollBar /template/ RepeatButton.line /template/ Path#Arrow" > <Style Selector="^ /template/ ContentPresenter" >
<Setter Property="Fill" Value="{DynamicResource ScrollBarButtonArrowForeground}" /> <Setter Property="Background" Value="{DynamicResource ScrollBarButtonBackgroundPressed}" />
</Style> <Setter Property="BorderBrush" Value="{DynamicResource ScrollBarButtonBorderBrushPressed}" />
</Style>
</Style>
<Style Selector="ScrollBar /template/ RepeatButton.line:pointerover /template/ Path#Arrow" > <Style Selector="^:disabled">
<Setter Property="Fill" Value="{DynamicResource ScrollBarButtonArrowForegroundPointerOver}" /> <Setter Property="TextElement.Foreground" Value="{DynamicResource ScrollBarButtonArrowForegroundDisabled}"/>
</Style>
<Style Selector="ScrollBar /template/ RepeatButton.line:pressed /template/ Path#Arrow" > <Style Selector="^ /template/ ContentPresenter" >
<Setter Property="Fill" Value="{DynamicResource ScrollBarButtonArrowForegroundPressed}" /> <Setter Property="Background" Value="{DynamicResource ScrollBarButtonBackgroundDisabled}" />
</Style> <Setter Property="BorderBrush" Value="{DynamicResource ScrollBarButtonBorderBrushDisabled}" />
</Style>
</Style>
</ControlTheme>
<Style Selector="ScrollBar /template/ RepeatButton.line:disabled /template/ Path#Arrow" > <ControlTheme x:Key="{x:Type ScrollBar}" TargetType="ScrollBar">
<Setter Property="Fill" Value="{DynamicResource ScrollBarButtonArrowForegroundDisabled}" /> <Setter Property="MinWidth" Value="{DynamicResource ScrollBarSize}" />
</Style> <Setter Property="MinHeight" Value="{DynamicResource ScrollBarSize}" />
<Setter Property="Background" Value="{DynamicResource ScrollBarBackground}" />
<Style Selector="ScrollBar[IsExpanded=true] /template/ RepeatButton.line"> <Setter Property="Foreground" Value="{DynamicResource ScrollBarForeground}" />
<Setter Property="Opacity" Value="1" /> <Setter Property="BorderBrush" Value="{DynamicResource ScrollBarBorderBrush}" />
</Style>
<Style Selector="ScrollBar:vertical /template/ RepeatButton.line.up /template/ Path">
<Setter Property="Data"
Value="M 19.091797 14.970703 L 10 5.888672 L 0.908203 14.970703 L 0.029297 14.091797 L 10 4.111328 L 19.970703 14.091797 Z" />
</Style>
<Style Selector="ScrollBar:vertical /template/ RepeatButton.line.down /template/ Path">
<Setter Property="Data"
Value="M 18.935547 4.560547 L 19.814453 5.439453 L 10 15.253906 L 0.185547 5.439453 L 1.064453 4.560547 L 10 13.496094 Z" />
</Style>
<Style Selector="ScrollBar:horizontal /template/ RepeatButton.line.up /template/ Path">
<Setter Property="Data" Value="M 14.091797 19.970703 L 4.111328 10 L 14.091797 0.029297 L 14.970703 0.908203 L 5.888672 10 L 14.970703 19.091797 Z" />
</Style>
<Style Selector="ScrollBar:horizontal /template/ RepeatButton.line.down /template/ Path">
<Setter Property="Data" Value="M 5.029297 19.091797 L 14.111328 10 L 5.029297 0.908203 L 5.908203 0.029297 L 15.888672 10 L 5.908203 19.970703 Z" />
</Style>
<Style Selector="ScrollBar /template/ Rectangle#TrackRect">
<Setter Property="StrokeThickness" Value="{DynamicResource ScrollBarTrackBorderThemeThickness}" />
<Setter Property="Fill" Value="{DynamicResource ScrollBarTrackFill}" />
<Setter Property="Stroke" Value="{DynamicResource ScrollBarTrackStroke}" />
<Setter Property="Opacity" Value="0" />
<Setter Property="Transitions">
<Transitions>
<DoubleTransition Property="Opacity" Duration="0:0:0.1" />
</Transitions>
</Setter>
</Style>
<Style Selector="ScrollBar[IsExpanded=true] /template/ Rectangle#TrackRect">
<Setter Property="Fill" Value="{DynamicResource ScrollBarTrackFillPointerOver}" />
<Setter Property="Stroke" Value="{DynamicResource ScrollBarTrackStrokePointerOver}" />
<Setter Property="Opacity" Value="1" />
</Style>
<Style Selector="ScrollBar /template/ RepeatButton.largeIncrease">
<Setter Property="Template">
<ControlTemplate>
<Border Background="{TemplateBinding Background}" />
</ControlTemplate>
</Setter>
<Setter Property="Background" Value="Transparent" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Opacity" Value="0" />
</Style>
<Style Selector="ScrollBar[IsExpanded=true] /template/ RepeatButton.largeIncrease"> <Style Selector="^:vertical">
<Setter Property="Opacity" Value="1" /> <Setter Property="Template">
</Style> <ControlTemplate>
<Grid x:Name="Root">
<Border x:Name="VerticalRoot"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}">
<Grid RowDefinitions="Auto,*,Auto">
<Rectangle x:Name="TrackRect"
Fill="{DynamicResource ScrollBarTrackFill}"
Stroke="{DynamicResource ScrollBarTrackStroke}"
StrokeThickness="{DynamicResource ScrollBarTrackBorderThemeThickness}"
Opacity="0"
Grid.RowSpan="3">
<Rectangle.Transitions>
<Transitions>
<DoubleTransition Property="Opacity" Duration="0:0:0.1" />
</Transitions>
</Rectangle.Transitions>
</Rectangle>
<RepeatButton Name="PART_LineUpButton"
HorizontalAlignment="Center"
Theme="{StaticResource FluentScrollBarLineButton}"
Grid.Row="0"
Focusable="False"
MinWidth="{DynamicResource ScrollBarSize}"
Height="{DynamicResource ScrollBarSize}">
<PathIcon Data="M 19.091797 14.970703 L 10 5.888672 L 0.908203 14.970703 L 0.029297 14.091797 L 10 4.111328 L 19.970703 14.091797 Z"
Width="{DynamicResource ScrollBarButtonArrowIconFontSize}"
Height="{DynamicResource ScrollBarButtonArrowIconFontSize}"/>
</RepeatButton>
<Track Grid.Row="1"
Minimum="{TemplateBinding Minimum}"
Maximum="{TemplateBinding Maximum}"
Value="{TemplateBinding Value, Mode=TwoWay}"
ViewportSize="{TemplateBinding ViewportSize}"
Orientation="{TemplateBinding Orientation}"
IsDirectionReversed="True">
<Track.DecreaseButton>
<RepeatButton Name="PART_PageUpButton"
Classes="largeIncrease"
Theme="{StaticResource FluentScrollBarPageButton}"
Focusable="False" />
</Track.DecreaseButton>
<Track.IncreaseButton>
<RepeatButton Name="PART_PageDownButton"
Classes="largeIncrease"
Theme="{StaticResource FluentScrollBarPageButton}"
Focusable="False" />
</Track.IncreaseButton>
<Thumb Theme="{StaticResource FluentScrollBarThumb}"
Width="{DynamicResource ScrollBarSize}"
MinHeight="{DynamicResource ScrollBarSize}"
RenderTransform="{DynamicResource VerticalSmallScrollThumbScaleTransform}"
RenderTransformOrigin="100%,50%" />
</Track>
<RepeatButton Name="PART_LineDownButton"
HorizontalAlignment="Center"
Theme="{StaticResource FluentScrollBarLineButton}"
Grid.Row="2"
Focusable="False"
MinWidth="{DynamicResource ScrollBarSize}"
Height="{DynamicResource ScrollBarSize}">
<PathIcon Data="M 18.935547 4.560547 L 19.814453 5.439453 L 10 15.253906 L 0.185547 5.439453 L 1.064453 4.560547 L 10 13.496094 Z"
Width="{DynamicResource ScrollBarButtonArrowIconFontSize}"
Height="{DynamicResource ScrollBarButtonArrowIconFontSize}"/>
</RepeatButton>
</Grid>
</Border>
</Grid>
</ControlTemplate>
</Setter>
</Style>
</Styles> <Style Selector="^:horizontal">
<Setter Property="Template">
<ControlTemplate>
<Grid x:Name="Root">
<Border x:Name="HorizontalRoot"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}">
<Grid ColumnDefinitions="Auto,*,Auto">
<Rectangle x:Name="TrackRect"
Fill="{DynamicResource ScrollBarTrackFill}"
Stroke="{DynamicResource ScrollBarTrackStroke}"
StrokeThickness="{DynamicResource ScrollBarTrackBorderThemeThickness}"
Opacity="0"
Grid.ColumnSpan="3">
<Rectangle.Transitions>
<Transitions>
<DoubleTransition Property="Opacity" Duration="0:0:0.1" />
</Transitions>
</Rectangle.Transitions>
</Rectangle>
<RepeatButton Name="PART_LineUpButton"
Theme="{StaticResource FluentScrollBarLineButton}"
VerticalAlignment="Center"
Grid.Column="0"
Focusable="False"
MinHeight="{DynamicResource ScrollBarSize}"
Width="{DynamicResource ScrollBarSize}">
<PathIcon Data="M 14.091797 19.970703 L 4.111328 10 L 14.091797 0.029297 L 14.970703 0.908203 L 5.888672 10 L 14.970703 19.091797 Z"
Width="{DynamicResource ScrollBarButtonArrowIconFontSize}"
Height="{DynamicResource ScrollBarButtonArrowIconFontSize}"/>
</RepeatButton>
<Track Grid.Column="1"
Minimum="{TemplateBinding Minimum}"
Maximum="{TemplateBinding Maximum}"
Value="{TemplateBinding Value, Mode=TwoWay}"
ViewportSize="{TemplateBinding ViewportSize}"
Orientation="{TemplateBinding Orientation}">
<Track.DecreaseButton>
<RepeatButton Name="PART_PageUpButton"
Classes="largeIncrease"
Theme="{StaticResource FluentScrollBarPageButton}"
Focusable="False" />
</Track.DecreaseButton>
<Track.IncreaseButton>
<RepeatButton Name="PART_PageDownButton"
Classes="largeIncrease"
Theme="{StaticResource FluentScrollBarPageButton}"
Focusable="False" />
</Track.IncreaseButton>
<Thumb Theme="{StaticResource FluentScrollBarThumb}"
Height="{DynamicResource ScrollBarSize}"
MinWidth="{DynamicResource ScrollBarSize}"
RenderTransform="{DynamicResource HorizontalSmallScrollThumbScaleTransform}"
RenderTransformOrigin="50%,100%" />
</Track>
<RepeatButton Name="PART_LineDownButton"
Theme="{StaticResource FluentScrollBarLineButton}"
VerticalAlignment="Center"
Grid.Column="2"
Focusable="False"
MinHeight="{DynamicResource ScrollBarSize}"
Width="{DynamicResource ScrollBarSize}">
<PathIcon Data="M 5.029297 19.091797 L 14.111328 10 L 5.029297 0.908203 L 5.908203 0.029297 L 15.888672 10 L 5.908203 19.970703 Z"
Width="{DynamicResource ScrollBarButtonArrowIconFontSize}"
Height="{DynamicResource ScrollBarButtonArrowIconFontSize}"/>
</RepeatButton>
</Grid>
</Border>
</Grid>
</ControlTemplate>
</Setter>
</Style>
<Style Selector="^[IsExpanded=true]">
<Style Selector="^ /template/ Grid#Root">
<Setter Property="Background" Value="{DynamicResource ScrollBarBackgroundPointerOver}" />
</Style>
<Style Selector="^ /template/ Rectangle#TrackRect">
<Setter Property="Fill" Value="{DynamicResource ScrollBarTrackFillPointerOver}" />
<Setter Property="Stroke" Value="{DynamicResource ScrollBarTrackStrokePointerOver}" />
<Setter Property="Opacity" Value="1" />
</Style>
<Style Selector="^ /template/ Thumb">
<Setter Property="Background" Value="{DynamicResource ScrollBarThumbBackgroundColor}" />
<Setter Property="RenderTransform" Value="none" />
</Style>
<Style Selector="^ /template/ RepeatButton">
<Setter Property="Opacity" Value="1" />
</Style>
</Style>
</ControlTheme>
</ResourceDictionary>

152
src/Avalonia.Themes.Fluent/Controls/ScrollViewer.xaml

@ -1,24 +1,26 @@
<Styles xmlns="https://github.com/avaloniaui" <ResourceDictionary
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="https://github.com/avaloniaui"
xmlns:converters="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls">
<Design.PreviewWith> <Design.PreviewWith>
<Grid ColumnDefinitions="*,20,*" <ScrollViewer Width="200" Height="200"
Height="300" HorizontalScrollBarVisibility="Auto">
Width="200" <StackPanel Spacing="20" Width="210">
Margin="20"> <TextBlock>Item 1</TextBlock>
<ScrollViewer> <TextBlock>Item 2</TextBlock>
<Border Height="1000" Background="#ccc"/> <TextBlock>Item 3</TextBlock>
</ScrollViewer> <TextBlock>Item 4</TextBlock>
<ScrollViewer Grid.Column="2" Classes="menuscroller"> <TextBlock>Item 5</TextBlock>
<Border Height="1000" Background="#ccc"/> <TextBlock>Item 6</TextBlock>
</ScrollViewer> <TextBlock>Item 7</TextBlock>
</Grid> <TextBlock>Item 8</TextBlock>
<TextBlock>Item 9</TextBlock>
</StackPanel>
</ScrollViewer>
</Design.PreviewWith> </Design.PreviewWith>
<Style Selector="ScrollViewer"> <ControlTheme x:Key="{x:Type ScrollViewer}" TargetType="ScrollViewer">
<Setter Property="Background" <Setter Property="Background" Value="Transparent" />
Value="Transparent" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Grid ColumnDefinitions="*,Auto" RowDefinitions="*,Auto"> <Grid ColumnDefinitions="*,Auto" RowDefinitions="*,Auto">
@ -37,9 +39,8 @@
Viewport="{TemplateBinding Viewport, Mode=TwoWay}" Viewport="{TemplateBinding Viewport, Mode=TwoWay}"
IsScrollChainingEnabled="{TemplateBinding IsScrollChainingEnabled}"> IsScrollChainingEnabled="{TemplateBinding IsScrollChainingEnabled}">
<ScrollContentPresenter.GestureRecognizers> <ScrollContentPresenter.GestureRecognizers>
<ScrollGestureRecognizer <ScrollGestureRecognizer CanHorizontallyScroll="{TemplateBinding CanHorizontallyScroll}"
CanHorizontallyScroll="{TemplateBinding CanHorizontallyScroll}" CanVerticallyScroll="{TemplateBinding CanVerticallyScroll}" />
CanVerticallyScroll="{TemplateBinding CanVerticallyScroll}" />
</ScrollContentPresenter.GestureRecognizers> </ScrollContentPresenter.GestureRecognizers>
</ScrollContentPresenter> </ScrollContentPresenter>
<ScrollBar Name="PART_HorizontalScrollBar" <ScrollBar Name="PART_HorizontalScrollBar"
@ -64,97 +65,22 @@
Visibility="{TemplateBinding VerticalScrollBarVisibility}" Visibility="{TemplateBinding VerticalScrollBarVisibility}"
Grid.Column="1" Grid.Column="1"
Focusable="False" /> Focusable="False" />
<Panel x:Name="PART_ScrollBarsSeparator" Grid.Row="1" Grid.Column="1" Background="{DynamicResource ScrollViewerScrollBarsSeparatorBackground}" /> <Panel x:Name="PART_ScrollBarsSeparator"
Grid.Row="1"
Grid.Column="1"
Background="{DynamicResource ScrollViewerScrollBarsSeparatorBackground}"
Opacity="0">
<Panel.Transitions>
<Transitions>
<DoubleTransition Property="Opacity" Duration="0:0:0.1" />
</Transitions>
</Panel.Transitions>
</Panel>
</Grid> </Grid>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> <Style Selector="^[IsExpanded=true] /template/ Panel#PART_ScrollBarsSeparator">
<Setter Property="Opacity" Value="1" />
<Style Selector="ScrollViewer /template/ Panel#PART_ScrollBarsSeparator"> </Style>
<Setter Property="Opacity" Value="0" /> </ControlTheme>
<Setter Property="Transitions"> </ResourceDictionary>
<Transitions>
<DoubleTransition Property="Opacity" Duration="0:0:0.1" />
</Transitions>
</Setter>
</Style>
<Style Selector="ScrollViewer[IsExpanded=true] /template/ Panel#PART_ScrollBarsSeparator">
<Setter Property="Opacity" Value="1" />
</Style>
<Style Selector="ScrollViewer.menuscroller">
<Setter Property="Template">
<ControlTemplate>
<DockPanel>
<RepeatButton DockPanel.Dock="Top"
BorderThickness="0"
Background="Transparent"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Center"
RenderTransform="{x:Null}"
Command="{Binding LineUp, RelativeSource={RelativeSource TemplatedParent}}">
<RepeatButton.IsVisible>
<MultiBinding Converter="{x:Static converters:MenuScrollingVisibilityConverter.Instance}"
ConverterParameter="0">
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="VerticalScrollBarVisibility"/>
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Offset.Y"/>
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Extent.Height"/>
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Viewport.Height"/>
</MultiBinding>
</RepeatButton.IsVisible>
<Viewbox Width="{DynamicResource ScrollBarButtonArrowIconFontSize}"
Height="{DynamicResource ScrollBarButtonArrowIconFontSize}">
<Path VerticalAlignment="Center"
HorizontalAlignment="Center"
Data="M 19.091797 14.970703 L 10 5.888672 L 0.908203 14.970703 L 0.029297 14.091797 L 10 4.111328 L 19.970703 14.091797 Z"
Width="20"
Height="20" />
</Viewbox>
</RepeatButton>
<RepeatButton DockPanel.Dock="Bottom"
BorderThickness="0"
Background="Transparent"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Center"
RenderTransform="{x:Null}"
Command="{Binding LineDown, RelativeSource={RelativeSource TemplatedParent}}">
<RepeatButton.IsVisible>
<MultiBinding Converter="{x:Static converters:MenuScrollingVisibilityConverter.Instance}"
ConverterParameter="100">
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="VerticalScrollBarVisibility"/>
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Offset.Y"/>
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Extent.Height"/>
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Viewport.Height"/>
</MultiBinding>
</RepeatButton.IsVisible>
<Viewbox Width="{DynamicResource ScrollBarButtonArrowIconFontSize}"
Height="{DynamicResource ScrollBarButtonArrowIconFontSize}">
<Path VerticalAlignment="Center"
HorizontalAlignment="Center"
Data="M 18.935547 4.560547 L 19.814453 5.439453 L 10 15.253906 L 0.185547 5.439453 L 1.064453 4.560547 L 10 13.496094 Z"
Width="20"
Height="20" />
</Viewbox>
</RepeatButton>
<ScrollContentPresenter Name="PART_ContentPresenter"
CanHorizontallyScroll="{TemplateBinding CanHorizontallyScroll}"
CanVerticallyScroll="{TemplateBinding CanVerticallyScroll}"
Content="{TemplateBinding Content}"
Extent="{TemplateBinding Extent, Mode=TwoWay}"
Margin="{TemplateBinding Padding}"
Offset="{TemplateBinding Offset, Mode=TwoWay}"
Viewport="{TemplateBinding Viewport, Mode=TwoWay}"/>
</DockPanel>
</ControlTemplate>
</Setter>
</Style>
<Style Selector="ScrollViewer.menuscroller /template/ RepeatButton > Viewbox > Path">
<Setter Property="Fill" Value="{DynamicResource ScrollBarButtonArrowForeground}" />
</Style>
<Style Selector="ScrollViewer.menuscroller /template/ RepeatButton:pointerover > Viewbox > Path">
<Setter Property="Fill" Value="{DynamicResource ScrollBarButtonArrowForegroundPointerOver}" />
</Style>
</Styles>

19
src/Avalonia.Themes.Fluent/Controls/Separator.xaml

@ -1,7 +1,11 @@
<Styles xmlns="https://github.com/avaloniaui"> <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style Selector="Separator"> <ControlTheme x:Key="{x:Type Separator}" TargetType="Separator">
<Setter Property="Focusable" Value="False"/> <Setter Property="Background" Value="{DynamicResource SystemControlForegroundBaseMediumLowBrush}" />
<Setter Property="Focusable" Value="False" />
<Setter Property="Height" Value="{DynamicResource MenuFlyoutSeparatorThemeHeight}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Margin" Value="{DynamicResource MenuFlyoutSeparatorThemePadding}" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Border Padding="{TemplateBinding Margin}" <Border Padding="{TemplateBinding Margin}"
@ -11,9 +15,8 @@
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}" CornerRadius="{TemplateBinding CornerRadius}"
Background="{TemplateBinding Background}"/> Background="{TemplateBinding Background}" />
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> </ControlTheme>
</ResourceDictionary>
</Styles>

606
src/Avalonia.Themes.Fluent/Controls/Slider.xaml

@ -1,275 +1,397 @@
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=netstandard">
<Design.PreviewWith> <Design.PreviewWith>
<Border Margin="20" Width="200" Height="200"> <Border Margin="20" Width="400" Height="600">
<DockPanel LastChildFill="True"> <DockPanel LastChildFill="True">
<StackPanel Spacing="10" DockPanel.Dock="Top"> <StackPanel Spacing="10" DockPanel.Dock="Top">
<Slider Value="50" /> <Slider Value="50" />
<Slider IsDirectionReversed="True" Value="50" />
<Slider Value="50" TickPlacement="TopLeft" TickFrequency="10"/>
<Slider Value="50" TickPlacement="BottomRight" TickFrequency="10"/>
<Slider Value="50" TickPlacement="Outside" TickFrequency="10"/>
<Slider IsEnabled="False" Value="50" /> <Slider IsEnabled="False" Value="50" />
<Slider Value="50">
<DataValidationErrors.Error>
<sys:Exception>
<x:Arguments>
<x:String>Error</x:String>
</x:Arguments>
</sys:Exception>
</DataValidationErrors.Error>
</Slider>
</StackPanel> </StackPanel>
<StackPanel Spacing="10" Orientation="Horizontal"> <StackPanel Spacing="10" Orientation="Horizontal">
<Slider Value="50" Orientation="Vertical" /> <Slider Value="50" Orientation="Vertical" />
<Slider IsDirectionReversed="True" Value="50" Orientation="Vertical" />
<Slider IsEnabled="False" Orientation="Vertical" Value="50" /> <Slider IsEnabled="False" Orientation="Vertical" Value="50" />
<Slider Value="50" TickPlacement="TopLeft" TickFrequency="10" Orientation="Vertical" />
<Slider Value="50" TickPlacement="BottomRight" TickFrequency="10" Orientation="Vertical" />
<Slider Value="50" TickPlacement="Outside" TickFrequency="10" Orientation="Vertical" />
</StackPanel> </StackPanel>
</DockPanel> </DockPanel>
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Styles.Resources>
<Thickness x:Key="SliderTopHeaderMargin">0,0,0,4</Thickness> <Thickness x:Key="SliderTopHeaderMargin">0,0,0,4</Thickness>
<GridLength x:Key="SliderPreContentMargin">15</GridLength> <GridLength x:Key="SliderPreContentMargin">15</GridLength>
<GridLength x:Key="SliderPostContentMargin">15</GridLength> <GridLength x:Key="SliderPostContentMargin">15</GridLength>
<x:Double x:Key="SliderHorizontalHeight">32</x:Double> <x:Double x:Key="SliderHorizontalHeight">32</x:Double>
<x:Double x:Key="SliderVerticalWidth">32</x:Double> <x:Double x:Key="SliderVerticalWidth">32</x:Double>
<CornerRadius x:Key="SliderThumbCornerRadius">10</CornerRadius> <CornerRadius x:Key="SliderThumbCornerRadius">10</CornerRadius>
<x:Double x:Key="SliderHorizontalThumbWidth">20</x:Double> <x:Double x:Key="SliderHorizontalThumbWidth">20</x:Double>
<x:Double x:Key="SliderHorizontalThumbHeight">20</x:Double> <x:Double x:Key="SliderHorizontalThumbHeight">20</x:Double>
<x:Double x:Key="SliderVerticalThumbWidth">20</x:Double> <x:Double x:Key="SliderVerticalThumbWidth">20</x:Double>
<x:Double x:Key="SliderVerticalThumbHeight">20</x:Double> <x:Double x:Key="SliderVerticalThumbHeight">20</x:Double>
</Styles.Resources>
<Style Selector="Thumb.SliderThumbStyle"> <ControlTheme x:Key="FluentSliderHorizontalRepeatButton" TargetType="RepeatButton">
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <ControlTemplate>
<ControlTemplate> <Grid>
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{DynamicResource SliderThumbCornerRadius}" /> <Border Name="FocusTarget" Margin="0,-10" Background="Transparent" />
</ControlTemplate> <Border Name="TrackBackground"
</Setter.Value> Background="{TemplateBinding Background}"
CornerRadius="{DynamicResource ControlCornerRadius}"
Height="{DynamicResource SliderTrackThemeHeight}"
VerticalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Setter> </Setter>
</Style> </ControlTheme>
<Style Selector="Slider:horizontal">
<Setter Property="Background" Value="{DynamicResource SliderTrackFill}" /> <ControlTheme x:Key="FluentSliderVerticalRepeatButton" TargetType="RepeatButton">
<Setter Property="BorderThickness" Value="{DynamicResource SliderBorderThemeThickness}" />
<Setter Property="Foreground" Value="{DynamicResource SliderTrackValueFill}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<DataValidationErrors> <Grid>
<Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="{TemplateBinding CornerRadius}"> <Border Name="FocusTarget" Margin="0,-10" Background="Transparent" />
<Grid Name="grid" Margin="{TemplateBinding Padding}" RowDefinitions="Auto, *"> <Border Name="TrackBackground"
<ContentPresenter x:Name="HeaderContentPresenter" Grid.Row="0" TextElement.FontWeight="{DynamicResource SliderHeaderThemeFontWeight}" TextElement.Foreground="{DynamicResource SliderHeaderForeground}" Background="{TemplateBinding Background}"
Margin="{DynamicResource SliderTopHeaderMargin}" /> CornerRadius="{DynamicResource ControlCornerRadius}"
<Grid x:Name="SliderContainer" Grid.Row="1"> Width="{DynamicResource SliderTrackThemeHeight}"
<Grid.Styles> HorizontalAlignment="Center"/>
<Style Selector="TickBar"> </Grid>
<Setter Property="ReservedSpace" Value="{Binding #PART_Track.Thumb.Bounds}" />
</Style>
</Grid.Styles>
<Grid x:Name="HorizontalTemplate" ColumnDefinitions="Auto,Auto,*" MinHeight="{DynamicResource SliderHorizontalHeight}">
<Grid.RowDefinitions>
<RowDefinition Height="{DynamicResource SliderPreContentMargin}" />
<RowDefinition Height="Auto" />
<RowDefinition Height="{DynamicResource SliderPostContentMargin}" />
</Grid.RowDefinitions>
<TickBar Name="TopTickBar" Placement="Top" Height="{DynamicResource SliderOutsideTickBarThemeHeight}" VerticalAlignment="Bottom" Margin="0,0,0,4" Grid.ColumnSpan="3" />
<!-- <TickBar Name="HorizontalInlineTickBar" Placement="Top" Fill="{DynamicResource SliderInlineTickBarFill}" Height="{DynamicResource SliderTrackThemeHeight}" Grid.Row="1" Grid.ColumnSpan="3" /> -->
<TickBar Name="BottomTickBar" Placement="Bottom" Height="{DynamicResource SliderOutsideTickBarThemeHeight}" VerticalAlignment="Top" Margin="0,4,0,0" Grid.Row="2" Grid.ColumnSpan="3" />
<Track Name="PART_Track" Grid.Row="1" Grid.ColumnSpan="3" IsDirectionReversed="{TemplateBinding IsDirectionReversed}" Orientation="Horizontal">
<Track.DecreaseButton>
<RepeatButton Name="PART_DecreaseButton" Background="{TemplateBinding Foreground}" Focusable="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<RepeatButton.Template>
<ControlTemplate>
<Grid>
<Border Name="FocusTarget" Background="Transparent" Margin="0,-10" />
<Border Name="TrackBackground" Background="{TemplateBinding Background}" CornerRadius="{DynamicResource ControlCornerRadius}" Height="{DynamicResource SliderTrackThemeHeight}" VerticalAlignment="Center" />
</Grid>
</ControlTemplate>
</RepeatButton.Template>
</RepeatButton>
</Track.DecreaseButton>
<Track.IncreaseButton>
<RepeatButton Name="PART_IncreaseButton" Background="{TemplateBinding Background}" Focusable="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<RepeatButton.Template>
<ControlTemplate>
<Grid>
<Border Name="FocusTarget" Background="Transparent" Margin="0,-10" />
<Border Name="TrackBackground" Background="{TemplateBinding Background}" CornerRadius="{DynamicResource ControlCornerRadius}" Height="{DynamicResource SliderTrackThemeHeight}" VerticalAlignment="Center" />
</Grid>
</ControlTemplate>
</RepeatButton.Template>
</RepeatButton>
</Track.IncreaseButton>
<Thumb Classes="SliderThumbStyle" Name="thumb" Margin="0" Padding="0" DataContext="{TemplateBinding Value}" Height="{DynamicResource SliderHorizontalThumbHeight}" Width="{DynamicResource SliderHorizontalThumbWidth}" />
</Track>
</Grid>
</Grid>
</Grid>
</Border>
</DataValidationErrors>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> </ControlTheme>
<Style Selector="Slider:vertical">
<ControlTheme x:Key="FluentSliderThumbTheme" TargetType="Thumb">
<Setter Property="Template">
<ControlTemplate>
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{DynamicResource SliderThumbCornerRadius}" />
</ControlTemplate>
</Setter>
</ControlTheme>
<ControlTheme x:Key="{x:Type Slider}" TargetType="Slider">
<Setter Property="Background" Value="{DynamicResource SliderTrackFill}" /> <Setter Property="Background" Value="{DynamicResource SliderTrackFill}" />
<Setter Property="BorderThickness" Value="{DynamicResource SliderBorderThemeThickness}" /> <Setter Property="BorderThickness" Value="{DynamicResource SliderBorderThemeThickness}" />
<Setter Property="Foreground" Value="{DynamicResource SliderTrackValueFill}" /> <Setter Property="Foreground" Value="{DynamicResource SliderTrackValueFill}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="Template"> <Style Selector="^:horizontal">
<ControlTemplate> <Setter Property="Template">
<DataValidationErrors> <ControlTemplate>
<Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="{TemplateBinding CornerRadius}"> <DataValidationErrors>
<Grid Name="grid" Margin="{TemplateBinding Padding}" RowDefinitions="Auto, *"> <Border
<ContentPresenter x:Name="HeaderContentPresenter" Grid.Row="0" TextElement.FontWeight="{DynamicResource SliderHeaderThemeFontWeight}" TextElement.Foreground="{DynamicResource SliderHeaderForeground}" BorderBrush="{TemplateBinding BorderBrush}"
Margin="{DynamicResource SliderTopHeaderMargin}" /> BorderThickness="{TemplateBinding BorderThickness}"
<Grid x:Name="SliderContainer" Grid.Row="1"> CornerRadius="{TemplateBinding CornerRadius}">
<Grid.Styles> <Grid
<Style Selector="TickBar"> Name="grid"
<Setter Property="ReservedSpace" Value="{Binding #PART_Track.Thumb.Bounds}" /> Margin="{TemplateBinding Padding}"
</Style> RowDefinitions="Auto, *">
</Grid.Styles> <ContentPresenter
<Grid x:Name="VerticalTemplate" RowDefinitions="*,Auto,Auto" MinWidth="{DynamicResource SliderVerticalWidth}"> x:Name="HeaderContentPresenter"
<Grid.ColumnDefinitions> Grid.Row="0"
<ColumnDefinition Width="{DynamicResource SliderPreContentMargin}" /> Margin="{DynamicResource SliderTopHeaderMargin}"
<ColumnDefinition Width="Auto" /> TextElement.FontWeight="{DynamicResource SliderHeaderThemeFontWeight}"
<ColumnDefinition Width="{DynamicResource SliderPostContentMargin}" /> TextElement.Foreground="{DynamicResource SliderHeaderForeground}" />
</Grid.ColumnDefinitions> <Grid x:Name="SliderContainer"
<TickBar Name="LeftTickBar" Placement="Left" Width="{DynamicResource SliderOutsideTickBarThemeHeight}" HorizontalAlignment="Right" Margin="0,0,4,0" Grid.RowSpan="3" /> Grid.Row="1"
<!-- <TickBar Name="VerticalInlineTickBar" Placement="Inline" Fill="{DynamicResource SliderInlineTickBarFill}" Width="{DynamicResource SliderTrackThemeHeight}" Grid.Column="1" Grid.RowSpan="3" /> --> Background="{DynamicResource SliderContainerBackground}">
<TickBar Name="RightTickBar" Placement="Right" Width="{DynamicResource SliderOutsideTickBarThemeHeight}" HorizontalAlignment="Left" Margin="4,0,0,0" Grid.Column="2" Grid.RowSpan="3" /> <Grid.Styles>
<Track Name="PART_Track" Grid.Column="1" Grid.ColumnSpan="1" Grid.RowSpan="3" IsDirectionReversed="{TemplateBinding IsDirectionReversed}" Orientation="Vertical"> <Style Selector="TickBar">
<Track.DecreaseButton> <Setter Property="ReservedSpace" Value="{Binding #PART_Track.Thumb.Bounds}" />
<RepeatButton Name="PART_DecreaseButton" Background="{TemplateBinding Foreground}" Focusable="False" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> </Style>
<RepeatButton.Template> </Grid.Styles>
<ControlTemplate> <Grid
<Grid> x:Name="HorizontalTemplate"
<Border Name="FocusTarget" Background="Transparent" Margin="0,-10" /> MinHeight="{DynamicResource SliderHorizontalHeight}"
<Border Name="TrackBackground" Background="{TemplateBinding Background}" CornerRadius="{DynamicResource ControlCornerRadius}" Width="{DynamicResource SliderTrackThemeHeight}" HorizontalAlignment="Center" /> ColumnDefinitions="Auto,Auto,*">
</Grid> <Grid.RowDefinitions>
</ControlTemplate> <RowDefinition Height="{DynamicResource SliderPreContentMargin}" />
</RepeatButton.Template> <RowDefinition Height="Auto" />
</RepeatButton> <RowDefinition Height="{DynamicResource SliderPostContentMargin}" />
</Track.DecreaseButton> </Grid.RowDefinitions>
<Track.IncreaseButton> <TickBar
<RepeatButton Name="PART_IncreaseButton" Background="{TemplateBinding Background}" Focusable="False" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> Name="TopTickBar"
<RepeatButton.Template> Grid.ColumnSpan="3"
<ControlTemplate> Ticks="{TemplateBinding Ticks}"
<Grid> TickFrequency="{TemplateBinding Slider.TickFrequency}"
<Border Name="FocusTarget" Background="Transparent" Margin="0,-10" /> Orientation="{TemplateBinding Slider.Orientation}"
<Border Name="TrackBackground" Background="{TemplateBinding Background}" CornerRadius="{DynamicResource ControlCornerRadius}" Width="{DynamicResource SliderTrackThemeHeight}" HorizontalAlignment="Center" /> Minimum="{TemplateBinding Slider.Minimum}"
</Grid> Maximum="{TemplateBinding Slider.Maximum}"
</ControlTemplate> Height="{DynamicResource SliderOutsideTickBarThemeHeight}"
</RepeatButton.Template> Margin="0,0,0,4"
</RepeatButton> VerticalAlignment="Bottom"
</Track.IncreaseButton> Placement="Top"
<Thumb Classes="SliderThumbStyle" Name="SliderThumb" Margin="0" Padding="0" DataContext="{TemplateBinding Value}" Height="{DynamicResource SliderVerticalThumbHeight}" Width="{DynamicResource SliderVerticalThumbWidth}" /> IsVisible="False"
</Track> Fill="{DynamicResource SliderTickBarFill}"/>
<TickBar
Name="BottomTickBar"
Grid.Row="2"
Grid.ColumnSpan="3"
Ticks="{TemplateBinding Ticks}"
TickFrequency="{TemplateBinding Slider.TickFrequency}"
Orientation="{TemplateBinding Slider.Orientation}"
Minimum="{TemplateBinding Slider.Minimum}"
Maximum="{TemplateBinding Slider.Maximum}"
Height="{DynamicResource SliderOutsideTickBarThemeHeight}"
Margin="0,4,0,0"
VerticalAlignment="Top"
Placement="Bottom"
IsVisible="False"
Fill="{DynamicResource SliderTickBarFill}" />
<Track
Name="PART_Track"
Grid.Row="1"
Grid.ColumnSpan="3"
Minimum="{TemplateBinding Minimum}"
Maximum="{TemplateBinding Maximum}"
Value="{TemplateBinding Value, Mode=TwoWay}"
IsDirectionReversed="{TemplateBinding IsDirectionReversed}"
Orientation="Horizontal">
<Track.DecreaseButton>
<RepeatButton
Name="PART_DecreaseButton"
Theme="{StaticResource FluentSliderHorizontalRepeatButton}"
Background="{TemplateBinding Foreground}"
Focusable="False"/>
</Track.DecreaseButton>
<Track.IncreaseButton>
<RepeatButton
Name="PART_IncreaseButton"
Theme="{StaticResource FluentSliderHorizontalRepeatButton}"
Background="{TemplateBinding Background}"
Focusable="False"/>
</Track.IncreaseButton>
<Thumb
Name="thumb"
Width="{DynamicResource SliderHorizontalThumbWidth}"
Height="{DynamicResource SliderHorizontalThumbHeight}"
Margin="0"
Padding="0"
Background="{DynamicResource SliderThumbBackground}"
BorderThickness="0"
Theme="{StaticResource FluentSliderThumbTheme}"
DataContext="{TemplateBinding Value}"/>
</Track>
</Grid>
</Grid> </Grid>
</Grid> </Grid>
</Grid> </Border>
</Border> </DataValidationErrors>
</DataValidationErrors> </ControlTemplate>
</ControlTemplate> </Setter>
</Setter> </Style>
</Style> <Style Selector="^:vertical">
<Style Selector="Slider /template/ Track#PART_Track"> <Setter Property="Template">
<Setter Property="Minimum" Value="{TemplateBinding Minimum}" /> <ControlTemplate>
<Setter Property="Maximum" Value="{TemplateBinding Maximum}" /> <DataValidationErrors>
<Setter Property="Value" Value="{TemplateBinding Value, Mode=TwoWay}" /> <Border
</Style> BorderBrush="{TemplateBinding BorderBrush}"
<Style Selector="Slider /template/ TickBar"> BorderThickness="{TemplateBinding BorderThickness}"
<Setter Property="Fill" Value="{DynamicResource SliderTickBarFill}" /> CornerRadius="{TemplateBinding CornerRadius}">
<Setter Property="TickFrequency" Value="{TemplateBinding Slider.TickFrequency}" /> <Grid
<Setter Property="Orientation" Value="{TemplateBinding Slider.Orientation}" /> Name="grid"
<Setter Property="Minimum" Value="{TemplateBinding Slider.Minimum}" /> Margin="{TemplateBinding Padding}"
<Setter Property="Maximum" Value="{TemplateBinding Slider.Maximum}" /> RowDefinitions="Auto, *">
</Style> <ContentPresenter
x:Name="HeaderContentPresenter"
<!-- Normal State --> Grid.Row="0"
Margin="{DynamicResource SliderTopHeaderMargin}"
<Style Selector="Slider /template/ Thumb.SliderThumbStyle"> TextElement.FontWeight="{DynamicResource SliderHeaderThemeFontWeight}"
<Setter Property="Background" Value="{DynamicResource SliderThumbBackground}" /> TextElement.Foreground="{DynamicResource SliderHeaderForeground}" />
</Style> <Grid x:Name="SliderContainer"
Grid.Row="1"
Background="{DynamicResource SliderContainerBackground}">
<Grid.Styles>
<Style Selector="TickBar">
<Setter Property="ReservedSpace" Value="{Binding #PART_Track.Thumb.Bounds}" />
</Style>
</Grid.Styles>
<Grid
x:Name="VerticalTemplate"
MinWidth="{DynamicResource SliderVerticalWidth}"
RowDefinitions="*,Auto,Auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{DynamicResource SliderPreContentMargin}" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="{DynamicResource SliderPostContentMargin}" />
</Grid.ColumnDefinitions>
<TickBar
Name="LeftTickBar"
Grid.RowSpan="3"
Ticks="{TemplateBinding Ticks}"
TickFrequency="{TemplateBinding Slider.TickFrequency}"
Orientation="{TemplateBinding Slider.Orientation}"
Minimum="{TemplateBinding Slider.Minimum}"
Maximum="{TemplateBinding Slider.Maximum}"
Width="{DynamicResource SliderOutsideTickBarThemeHeight}"
Margin="0,0,4,0"
HorizontalAlignment="Right"
Placement="Left"
IsVisible="False"
Fill="{DynamicResource SliderTickBarFill}"/>
<TickBar
Name="RightTickBar"
Grid.RowSpan="3"
Grid.Column="2"
Ticks="{TemplateBinding Ticks}"
TickFrequency="{TemplateBinding Slider.TickFrequency}"
Orientation="{TemplateBinding Slider.Orientation}"
Minimum="{TemplateBinding Slider.Minimum}"
Maximum="{TemplateBinding Slider.Maximum}"
Width="{DynamicResource SliderOutsideTickBarThemeHeight}"
Margin="4,0,0,0"
HorizontalAlignment="Left"
Placement="Right"
IsVisible="False"
Fill="{DynamicResource SliderTickBarFill}"/>
<Track
Name="PART_Track"
Grid.RowSpan="3"
Grid.Column="1"
Grid.ColumnSpan="1"
Minimum="{TemplateBinding Minimum}"
Maximum="{TemplateBinding Maximum}"
Value="{TemplateBinding Value, Mode=TwoWay}"
IsDirectionReversed="{TemplateBinding IsDirectionReversed}"
Orientation="Vertical">
<Track.DecreaseButton>
<RepeatButton
Name="PART_DecreaseButton"
Theme="{StaticResource FluentSliderVerticalRepeatButton}"
Background="{TemplateBinding Foreground}"
Focusable="False"/>
</Track.DecreaseButton>
<Track.IncreaseButton>
<RepeatButton
Name="PART_IncreaseButton"
Background="{TemplateBinding Background}"
Theme="{StaticResource FluentSliderVerticalRepeatButton}"
Focusable="False"/>
</Track.IncreaseButton>
<Thumb
Name="SliderThumb"
Width="{DynamicResource SliderVerticalThumbWidth}"
Height="{DynamicResource SliderVerticalThumbHeight}"
Margin="0"
Padding="0"
Background="{DynamicResource SliderThumbBackground}"
BorderThickness="0"
Theme="{StaticResource FluentSliderThumbTheme}"
DataContext="{TemplateBinding Value}" />
</Track>
</Grid>
</Grid>
</Grid>
</Border>
</DataValidationErrors>
</ControlTemplate>
</Setter>
</Style>
<Style Selector="Slider /template/ Grid#SliderContainer"> <!-- TickBar Placement States -->
<Setter Property="Background" Value="{DynamicResource SliderContainerBackground}" />
</Style>
<Style Selector="Slider /template/ TickBar"> <Style Selector="^[TickPlacement=TopLeft] /template/ TickBar#LeftTickBar, ^[TickPlacement=Outside] /template/ TickBar#LeftTickBar">
<Setter Property="IsVisible" Value="False" /> <Setter Property="IsVisible" Value="True" />
<Setter Property="Ticks" Value="{TemplateBinding Ticks}" /> </Style>
</Style>
<!-- TickBar Placement States --> <Style Selector="^[TickPlacement=TopLeft] /template/ TickBar#TopTickBar, ^[TickPlacement=Outside] /template/ TickBar#TopTickBar">
<Setter Property="IsVisible" Value="True" />
</Style>
<Style Selector="Slider[TickPlacement=TopLeft] /template/ TickBar#LeftTickBar, Slider[TickPlacement=Outside] /template/ TickBar#LeftTickBar"> <Style Selector="^[TickPlacement=BottomRight] /template/ TickBar#BottomTickBar, ^[TickPlacement=Outside] /template/ TickBar#BottomTickBar">
<Setter Property="IsVisible" Value="True" /> <Setter Property="IsVisible" Value="True" />
</Style> </Style>
<Style Selector="Slider[TickPlacement=TopLeft] /template/ TickBar#TopTickBar, Slider[TickPlacement=Outside] /template/ TickBar#TopTickBar">
<Setter Property="IsVisible" Value="True" />
</Style>
<Style Selector="Slider[TickPlacement=BottomRight] /template/ TickBar#BottomTickBar, Slider[TickPlacement=Outside] /template/ TickBar#BottomTickBar">
<Setter Property="IsVisible" Value="True" />
</Style>
<Style Selector="Slider[TickPlacement=BottomRight] /template/ TickBar#RightTickBar, Slider[TickPlacement=Outside] /template/ TickBar#RightTickBar">
<Setter Property="IsVisible" Value="True" />
</Style>
<!-- Disabled State -->
<Style Selector="Slider:disabled /template/ ContentPresenter#HeaderContentPresenter"> <Style Selector="^[TickPlacement=BottomRight] /template/ TickBar#RightTickBar, ^[TickPlacement=Outside] /template/ TickBar#RightTickBar">
<Setter Property="Foreground" Value="{DynamicResource SliderHeaderForegroundDisabled}" /> <Setter Property="IsVisible" Value="True" />
</Style> </Style>
<Style Selector="Slider:disabled /template/ RepeatButton#PART_DecreaseButton">
<Setter Property="Background" Value="{DynamicResource SliderTrackValueFillDisabled}" />
</Style>
<Style Selector="Slider:disabled /template/ RepeatButton#PART_IncreaseButton">
<Setter Property="Background" Value="{DynamicResource SliderTrackFillDisabled}" />
</Style>
<Style Selector="Slider:disabled /template/ Thumb.SliderThumbStyle">
<Setter Property="Background" Value="{DynamicResource SliderThumbBackgroundDisabled}" />
</Style>
<Style Selector="Slider:disabled /template/ TickBar">
<Setter Property="Fill" Value="{DynamicResource SliderTickBarFillDisabled}" />
</Style>
<Style Selector="Slider:pointerover /template/ Grid#SliderContainer">
<Setter Property="Background" Value="{DynamicResource SliderContainerBackgroundDisabled}" />
</Style>
<!-- PointerOver State --> <!-- Disabled State -->
<Style Selector="Slider:pointerover /template/ RepeatButton#PART_IncreaseButton">
<Setter Property="Background" Value="{DynamicResource SliderTrackFillPointerOver}" />
</Style>
<Style Selector="Slider:pointerover /template/ Thumb.SliderThumbStyle">
<Setter Property="Background" Value="{DynamicResource SliderThumbBackgroundPointerOver}" />
</Style>
<Style Selector="Slider:pointerover /template/ Grid#SliderContainer">
<Setter Property="Background" Value="{DynamicResource SliderContainerBackgroundPointerOver}" />
</Style>
<Style Selector="Slider:pointerover /template/ RepeatButton#PART_DecreaseButton">
<Setter Property="Background" Value="{DynamicResource SliderTrackValueFillPointerOver}" />
</Style>
<!-- Pressed State --> <Style Selector="^:disabled">
<Style Selector="Slider:pressed /template/ RepeatButton#PART_IncreaseButton"> <Style Selector="^ /template/ ContentPresenter#HeaderContentPresenter">
<Setter Property="Background" Value="{DynamicResource SliderTrackFillPressed}" /> <Setter Property="Foreground" Value="{DynamicResource SliderHeaderForegroundDisabled}" />
</Style> </Style>
<Style Selector="^ /template/ RepeatButton#PART_DecreaseButton">
<Setter Property="Background" Value="{DynamicResource SliderTrackValueFillDisabled}" />
</Style>
<Style Selector="Slider:pressed /template/ Thumb.SliderThumbStyle"> <Style Selector="^ /template/ RepeatButton#PART_IncreaseButton">
<Setter Property="Background" Value="{DynamicResource SliderThumbBackgroundPressed}" /> <Setter Property="Background" Value="{DynamicResource SliderTrackFillDisabled}" />
</Style> </Style>
<Style Selector="Slider:pointerover /template/ Grid#SliderContainer"> <Style Selector="^ /template/ Thumb">
<Setter Property="Background" Value="{DynamicResource SliderContainerBackgroundPressed}" /> <Setter Property="Background" Value="{DynamicResource SliderThumbBackgroundDisabled}" />
</Style> </Style>
<Style Selector="Slider:pointerover /template/ RepeatButton#PART_DecreaseButton"> <Style Selector="^ /template/ TickBar">
<Setter Property="Background" Value="{DynamicResource SliderTrackValueFillPressed}" /> <Setter Property="Fill" Value="{DynamicResource SliderTickBarFillDisabled}" />
</Style> </Style>
</Style>
<Style Selector="Slider:error /template/ Thumb.SliderThumbStyle">
<Setter Property="Background" Value="{DynamicResource SystemControlErrorTextForegroundBrush}" /> <!-- PointerOver State -->
</Style> <Style Selector="^:pointerover">
<Style Selector="^ /template/ Grid#SliderContainer">
<Style Selector="Slider:error"> <Setter Property="Background" Value="{DynamicResource SliderContainerBackgroundDisabled}" />
</Style>
<Style Selector="^ /template/ RepeatButton#PART_IncreaseButton">
<Setter Property="Background" Value="{DynamicResource SliderTrackFillPointerOver}" />
</Style>
<Style Selector="^ /template/ Thumb">
<Setter Property="Background" Value="{DynamicResource SliderThumbBackgroundPointerOver}" />
</Style>
<Style Selector="^ /template/ Grid#SliderContainer">
<Setter Property="Background" Value="{DynamicResource SliderContainerBackgroundPointerOver}" />
</Style>
<Style Selector="^ /template/ RepeatButton#PART_DecreaseButton">
<Setter Property="Background" Value="{DynamicResource SliderTrackValueFillPointerOver}" />
</Style>
</Style>
<!-- Pressed State -->
<Style Selector="^:pressed">
<Style Selector="^ /template/ Grid#SliderContainer">
<Setter Property="Background" Value="{DynamicResource SliderContainerBackgroundPressed}" />
</Style>
<Style Selector="^ /template/ RepeatButton#PART_DecreaseButton">
<Setter Property="Background" Value="{DynamicResource SliderTrackValueFillPressed}" />
</Style>
<Style Selector="^ /template/ RepeatButton#PART_IncreaseButton">
<Setter Property="Background" Value="{DynamicResource SliderTrackFillPressed}" />
</Style>
<Style Selector="^ /template/ Thumb">
<Setter Property="Background" Value="{DynamicResource SliderThumbBackgroundPressed}" />
</Style>
</Style>
<Style Selector="^:error">
<Setter Property="Foreground" Value="{DynamicResource SystemControlErrorTextForegroundBrush}" /> <Setter Property="Foreground" Value="{DynamicResource SystemControlErrorTextForegroundBrush}" />
</Style> <Style Selector="^ /template/ Thumb">
</Styles> <Setter Property="Background" Value="{DynamicResource SystemControlErrorTextForegroundBrush}" />
</Style>
</Style>
</ControlTheme>
</ResourceDictionary>

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

@ -1,37 +1,120 @@
<Styles xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:CompileBindings="True" x:CompileBindings="True"
xmlns:converters="using:Avalonia.Controls.Converters"> xmlns:converters="using:Avalonia.Controls.Converters">
<Design.PreviewWith> <Design.PreviewWith>
<Border Padding="60"> <Border Padding="60">
<StackPanel> <StackPanel Spacing="20">
<SplitButton Content="Hello World"> <SplitButton Content="SplitButton">
<SplitButton.Flyout>
<Flyout>Hello</Flyout>
</SplitButton.Flyout>
</SplitButton>
<SplitButton CornerRadius="16" Content="Rounded">
<SplitButton.Flyout> <SplitButton.Flyout>
<Flyout>Hello</Flyout> <Flyout>Hello</Flyout>
</SplitButton.Flyout> </SplitButton.Flyout>
</SplitButton> </SplitButton>
<ToggleSplitButton Content="Hello World"> <SplitButton IsEnabled="False">Disabled</SplitButton>
<ToggleSplitButton Content="ToggleSplitButton">
<ToggleSplitButton.Flyout>
<Flyout>Hello</Flyout>
</ToggleSplitButton.Flyout>
</ToggleSplitButton>
<ToggleSplitButton Content="Checked" IsChecked="True">
<ToggleSplitButton.Flyout> <ToggleSplitButton.Flyout>
<Flyout>Hello</Flyout> <Flyout>Hello</Flyout>
</ToggleSplitButton.Flyout> </ToggleSplitButton.Flyout>
</ToggleSplitButton> </ToggleSplitButton>
<ToggleSplitButton Content="Checked Disabled" IsChecked="True" IsEnabled="False"/>
</StackPanel> </StackPanel>
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Styles.Resources> <x:Double x:Key="SplitButtonPrimaryButtonSize">32</x:Double>
<x:Double x:Key="SplitButtonPrimaryButtonSize">32</x:Double> <x:Double x:Key="SplitButtonSecondaryButtonSize">32</x:Double>
<x:Double x:Key="SplitButtonSecondaryButtonSize">32</x:Double> <x:Double x:Key="SplitButtonSeparatorWidth">1</x:Double>
<x:Double x:Key="SplitButtonSeparatorWidth">1</x:Double> <x:Double x:Key="SplitButtonMinHeight">32</x:Double>
<x:Double x:Key="SplitButtonMinHeight">32</x:Double>
<converters:MarginMultiplierConverter x:Key="PrimaryButtonBorderMultiplier" Left="True" Top="True" Bottom="True" Indent="1" />
<converters:MarginMultiplierConverter x:Key="SecondaryButtonBorderMultiplier" Right="True" Top="True" Bottom="True" Indent="1" />
<converters:MarginMultiplierConverter x:Key="SeparatorBorderMultiplier" Top="True" Bottom="True" Indent="1" />
<converters:MarginMultiplierConverter x:Key="PrimaryButtonBorderMultiplier" Left="True" Top="True" Bottom="True" Indent="1" /> <ControlTheme x:Key="FluentSplitButtonComponent" TargetType="Button">
<converters:MarginMultiplierConverter x:Key="SecondaryButtonBorderMultiplier" Right="True" Top="True" Bottom="True" Indent="1" /> <Setter Property="Template">
<converters:MarginMultiplierConverter x:Key="SeparatorBorderMultiplier" Top="True" Bottom="True" Indent="1" /> <ControlTemplate>
</Styles.Resources> <ContentPresenter x:Name="PART_ContentPresenter"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Padding="{TemplateBinding Padding}"
RecognizesAccessKey="True"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
</ControlTemplate>
</Setter>
<Style Selector="SplitButton"> <Style Selector="^:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource SplitButtonBackgroundPointerOver}" />
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrushPointerOver}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPointerOver}" />
</Style>
<Style Selector="^:pressed /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource SplitButtonBackgroundPressed}" />
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrushPressed}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<Style Selector="^:disabled /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource SplitButtonBackgroundDisabled}" />
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrushDisabled}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundDisabled}" />
</Style>
<Style Selector="^[Tag=flyout-open] /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource SplitButtonBackgroundPressed}" />
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrushPressed}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<Style Selector="^[Tag=checked]">
<Style Selector="^ /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource SplitButtonBackgroundChecked}" />
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrushChecked}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundChecked}" />
</Style>
<Style Selector="^:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource SplitButtonBackgroundCheckedPointerOver}" />
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrushCheckedPointerOver}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPointerOver}" />
</Style>
<Style Selector="^:pressed /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource SplitButtonBackgroundCheckedPressed}" />
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrushCheckedPressed}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</Style>
<Style Selector="^:disabled /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource SplitButtonBackgroundCheckedDisabled}" />
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrushCheckedDisabled}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedDisabled}" />
</Style>
</Style>
<Style Selector="^[Tag=checked-flyout-open] /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource SplitButtonBackgroundCheckedPressed}" />
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrushCheckedPressed}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</Style>
</ControlTheme>
<ControlTheme x:Key="{x:Type SplitButton}" TargetType="SplitButton">
<Setter Property="Background" Value="{DynamicResource SplitButtonBackground}" /> <Setter Property="Background" Value="{DynamicResource SplitButtonBackground}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForeground}" /> <Setter Property="Foreground" Value="{DynamicResource SplitButtonForeground}" />
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrush}" />
@ -41,211 +124,83 @@
<Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> <Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="VerticalContentAlignment" Value="Center" />
<!--<Setter Property="UseSystemFocusVisuals" Value="True" />
<Setter Property="FocusVisualMargin" Value="-3" />-->
<Setter Property="KeyboardNavigation.IsTabStop" Value="True" /> <Setter Property="KeyboardNavigation.IsTabStop" Value="True" />
<Setter Property="Focusable" Value="True" /> <Setter Property="Focusable" Value="True" />
<Setter Property="Padding" Value="{DynamicResource ButtonPadding}" /> <Setter Property="Padding" Value="{DynamicResource ButtonPadding}" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" /> <Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <ControlTemplate>
<ControlTemplate> <Grid>
<Grid> <Grid.ColumnDefinitions>
<Grid.ColumnDefinitions> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions>
</Grid.ColumnDefinitions>
<Button x:Name="PART_PrimaryButton"
<Button x:Name="PART_PrimaryButton" Grid.Column="0"
Grid.Column="0" Theme="{StaticResource FluentSplitButtonComponent}"
MinWidth="{DynamicResource SplitButtonPrimaryButtonSize}" MinWidth="{DynamicResource SplitButtonPrimaryButtonSize}"
Foreground="{TemplateBinding Foreground}" Foreground="{TemplateBinding Foreground}"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness, Converter={StaticResource PrimaryButtonBorderMultiplier}}" BorderThickness="{TemplateBinding BorderThickness, Converter={StaticResource PrimaryButtonBorderMultiplier}}"
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
Content="{TemplateBinding Content}" Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplate="{TemplateBinding ContentTemplate}"
Command="{TemplateBinding Command}" Command="{TemplateBinding Command}"
CommandParameter="{TemplateBinding CommandParameter}" CommandParameter="{TemplateBinding CommandParameter}"
FontFamily="{TemplateBinding FontFamily}" CornerRadius="{TemplateBinding CornerRadius, Converter={StaticResource LeftCornerRadiusFilterConverter}}"
FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}"
FontWeight="{TemplateBinding FontWeight}" FontSize="{TemplateBinding FontSize}"
HorizontalAlignment="Stretch" FontWeight="{TemplateBinding FontWeight}"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="Stretch"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Focusable="False" Padding="{TemplateBinding Padding}"
KeyboardNavigation.IsTabStop="False" /> Focusable="False"
KeyboardNavigation.IsTabStop="False" />
<Border x:Name="SeparatorBorder"
Grid.Column="1" <Border x:Name="SeparatorBorder"
Background="Transparent" Grid.Column="1"
Width="{DynamicResource SplitButtonSeparatorWidth}" Background="Transparent"
BorderThickness="{TemplateBinding BorderThickness, Converter={StaticResource SeparatorBorderMultiplier}}" Width="{DynamicResource SplitButtonSeparatorWidth}"
BorderBrush="{TemplateBinding BorderBrush}" /> BorderThickness="{TemplateBinding BorderThickness, Converter={StaticResource SeparatorBorderMultiplier}}"
BorderBrush="{TemplateBinding BorderBrush}" />
<Button x:Name="PART_SecondaryButton"
Grid.Column="2" <Button x:Name="PART_SecondaryButton"
MinWidth="{DynamicResource SplitButtonSecondaryButtonSize}" Grid.Column="2"
BorderBrush="{TemplateBinding BorderBrush}" Theme="{StaticResource FluentSplitButtonComponent}"
Foreground="{TemplateBinding Foreground}" MinWidth="{DynamicResource SplitButtonSecondaryButtonSize}"
Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness, Converter={StaticResource SecondaryButtonBorderMultiplier}}" Foreground="{TemplateBinding Foreground}"
Padding="0" Background="{TemplateBinding Background}"
HorizontalContentAlignment="Center" BorderThickness="{TemplateBinding BorderThickness, Converter={StaticResource SecondaryButtonBorderMultiplier}}"
VerticalContentAlignment="Center" CornerRadius="{TemplateBinding CornerRadius, Converter={StaticResource RightCornerRadiusFilterConverter}}"
HorizontalAlignment="Stretch" Padding="0"
VerticalAlignment="Stretch" HorizontalContentAlignment="Center"
Focusable="False" VerticalContentAlignment="Center"
KeyboardNavigation.IsTabStop="False" /> HorizontalAlignment="Stretch"
</Grid> VerticalAlignment="Stretch"
</ControlTemplate> Focusable="False"
</Setter.Value> KeyboardNavigation.IsTabStop="False">
<PathIcon Height="12" Width="12"
Data="M1939 486L2029 576L1024 1581L19 576L109 486L1024 1401L1939 486Z" />
</Button>
</Grid>
</ControlTemplate>
</Setter> </Setter>
</Style>
<Style Selector="^:flyout-open /template/ Button">
<!-- Default overridable styles --> <Setter Property="Tag" Value="flyout-open" />
<Style Selector="SplitButton /template/ Button#PART_PrimaryButton"> </Style>
<Setter Property="CornerRadius" Value="{TemplateBinding CornerRadius, Converter={StaticResource LeftCornerRadiusFilterConverter}}" />
</Style> <Style Selector="^:checked /template/ Button">
<Style Selector="SplitButton /template/ Button#PART_SecondaryButton"> <Setter Property="Tag" Value="checked" />
<Setter Property="CornerRadius" Value="{TemplateBinding CornerRadius, Converter={StaticResource RightCornerRadiusFilterConverter}}" /> </Style>
<Setter Property="Content">
<Template> <Style Selector="^:checked:flyout-open /template/ Button">
<PathIcon Height="12" <Setter Property="Tag" Value="checked-flyout-open" />
Width="12" </Style>
Data="M1939 486L2029 576L1024 1581L19 576L109 486L1024 1401L1939 486Z" /> </ControlTheme>
</Template> </ResourceDictionary>
</Setter>
</Style>
<!-- Primary and Secondary buttons PointerOver State -->
<Style Selector="SplitButton /template/ Button#PART_PrimaryButton:pointerover /template/ ContentPresenter,
SplitButton /template/ Button#PART_SecondaryButton:pointerover /template/ ContentPresenter">
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundPointerOver}" />
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushPointerOver}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPointerOver}" />
</Style>
<Style Selector="SplitButton /template/ Button#PART_SecondaryButton:pointerover PathIcon">
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPointerOver}" />
</Style>
<!-- Primary and Secondary buttons Pressed State -->
<Style Selector="SplitButton /template/ Button#PART_PrimaryButton:pressed /template/ ContentPresenter,
SplitButton /template/ Button#PART_SecondaryButton:pressed /template/ ContentPresenter">
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundPressed}" />
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushPressed}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<Style Selector="SplitButton /template/ Button#PART_SecondaryButton:pressed PathIcon">
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<!-- SplitButton Pressed State -->
<Style Selector="SplitButton:pressed /template/ Button#PART_PrimaryButton /template/ ContentPresenter,
SplitButton:pressed /template/ Button#PART_SecondaryButton /template/ ContentPresenter,
SplitButton:pressed /template/ Border#SeparatorBorder">
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundPressed}" />
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushPressed}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<Style Selector="SplitButton:pressed /template/ Button#PART_SecondaryButton PathIcon">
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<!-- Primary and Secondary buttons Flyout Open State -->
<Style Selector="SplitButton:flyout-open /template/ Button#PART_PrimaryButton /template/ ContentPresenter,
SplitButton:flyout-open /template/ Button#PART_SecondaryButton /template/ ContentPresenter,
SplitButton:flyout-open /template/ Border#SeparatorBorder">
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundPressed}" />
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushPressed}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<Style Selector="SplitButton:flyout-open /template/ Button#PART_SecondaryButton PathIcon">
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<!-- Disabled State -->
<Style Selector="SplitButton:disabled /template/ Button#PART_PrimaryButton /template/ ContentPresenter,
SplitButton:disabled /template/ Button#PART_SecondaryButton /template/ ContentPresenter,
SplitButton:disabled /template/ Border#SeparatorBorder">
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundDisabled}" />
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushDisabled}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundDisabled}" />
</Style>
<Style Selector="SplitButton:disabled /template/ Button#PART_SecondaryButton PathIcon">
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundDisabled}" />
</Style>
<!-- Checked State -->
<Style Selector="SplitButton:checked /template/ Button#PART_PrimaryButton /template/ ContentPresenter,
SplitButton:checked /template/ Button#PART_SecondaryButton /template/ ContentPresenter,
SplitButton:checked /template/ Border#SeparatorBorder">
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundChecked}" />
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushChecked}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundChecked}" />
</Style>
<Style Selector="SplitButton:checked /template/ Button#PART_SecondaryButton PathIcon">
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundChecked}" />
</Style>
<!-- Checked PointerOver State -->
<Style Selector="SplitButton:checked /template/ Button#PART_PrimaryButton:pointerover /template/ ContentPresenter,
SplitButton:checked /template/ Button#PART_SecondaryButton:pointerover /template/ ContentPresenter">
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundCheckedPointerOver}" />
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushCheckedPointerOver}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPointerOver}" />
</Style>
<Style Selector="SplitButton:checked /template/ Button#PART_SecondaryButton:pointerover PathIcon">
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPointerOver}" />
</Style>
<!-- Checked Pressed State -->
<Style Selector="SplitButton:checked /template/ Button#PART_PrimaryButton:pressed /template/ ContentPresenter,
SplitButton:checked /template/ Button#PART_SecondaryButton:pressed /template/ ContentPresenter">
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundCheckedPressed}" />
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushCheckedPressed}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</Style>
<Style Selector="SplitButton:checked /template/ Button#PART_SecondaryButton:pressed PathIcon">
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</Style>
<!-- SplitButton Checked Pressed State -->
<Style Selector="SplitButton:pressed:checked /template/ Button#PART_PrimaryButton /template/ ContentPresenter,
SplitButton:pressed:checked /template/ Button#PART_SecondaryButton /template/ ContentPresenter,
SplitButton:pressed:checked /template/ Border#SeparatorBorder">
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundCheckedPressed}" />
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushCheckedPressed}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</Style>
<Style Selector="SplitButton:pressed:checked /template/ Button#PART_SecondaryButton PathIcon">
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</Style>
<!-- Checked Flyout Open State -->
<Style Selector="SplitButton:checked:flyout-open /template/ Button#PART_PrimaryButton /template/ ContentPresenter,
SplitButton:checked:flyout-open /template/ Button#PART_SecondaryButton /template/ ContentPresenter,
SplitButton:checked:flyout-open /template/ Border#SeparatorBorder">
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundCheckedPressed}" />
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushCheckedPressed}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</Style>
<Style Selector="SplitButton:checked:flyout-open /template/ Button#PART_SecondaryButton PathIcon">
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</Style>
<!-- Disabled Checked State -->
<Style Selector="SplitButton:checked:disabled /template/ Button#PART_PrimaryButton /template/ ContentPresenter,
SplitButton:checked:disabled /template/ Button#PART_SecondaryButton /template/ ContentPresenter,
SplitButton:checked:disabled /template/ Border#SeparatorBorder">
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundCheckedDisabled}" />
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushCheckedDisabled}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedDisabled}" />
</Style>
<Style Selector="SplitButton:checked:disabled /template/ Button#PART_SecondaryButton PathIcon">
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedDisabled}" />
</Style>
</Styles>

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save