Browse Source

Merge branch 'master' into tokenizer

pull/1125/head
Eli Arbel 9 years ago
committed by GitHub
parent
commit
50173c135f
  1. 11
      docs/tutorial/from-wpf.md
  2. 10
      samples/ControlCatalog/Pages/BorderPage.xaml
  3. 8
      samples/ControlCatalog/Pages/ButtonPage.xaml
  4. 2
      samples/ControlCatalog/Pages/ContextMenuPage.xaml
  5. 2
      samples/ControlCatalog/Pages/DropDownPage.xaml
  6. 8
      samples/ControlCatalog/Pages/LayoutTransformControlPage.xaml
  7. 4
      samples/ControlCatalog/SideBar.xaml
  8. 2
      samples/RenderTest/Pages/ClippingPage.xaml
  9. 8
      samples/RenderTest/Pages/DrawingPage.xaml
  10. 4
      samples/RenderTest/SideBar.xaml
  11. 14
      src/Avalonia.Themes.Default/Button.xaml
  12. 10
      src/Avalonia.Themes.Default/CheckBox.xaml
  13. 10
      src/Avalonia.Themes.Default/DropDown.xaml
  14. 4
      src/Avalonia.Themes.Default/EmbeddableControlRoot.xaml
  15. 8
      src/Avalonia.Themes.Default/GridSplitter.xaml
  16. 6
      src/Avalonia.Themes.Default/ListBox.xaml
  17. 18
      src/Avalonia.Themes.Default/MenuItem.xaml
  18. 2
      src/Avalonia.Themes.Default/PopupRoot.xaml
  19. 4
      src/Avalonia.Themes.Default/ProgressBar.xaml
  20. 10
      src/Avalonia.Themes.Default/RadioButton.xaml
  21. 8
      src/Avalonia.Themes.Default/ScrollBar.xaml
  22. 4
      src/Avalonia.Themes.Default/Separator.xaml
  23. 6
      src/Avalonia.Themes.Default/Slider.xaml
  24. 6
      src/Avalonia.Themes.Default/TabStripItem.xaml
  25. 22
      src/Avalonia.Themes.Default/TextBox.xaml
  26. 18
      src/Avalonia.Themes.Default/ToggleButton.xaml
  27. 6
      src/Avalonia.Themes.Default/ToolTip.xaml
  28. 4
      src/Avalonia.Themes.Default/TreeView.xaml
  29. 2
      src/Avalonia.Themes.Default/TreeViewItem.xaml
  30. 4
      src/Avalonia.Themes.Default/Window.xaml
  31. 68
      src/Avalonia.Visuals/Rendering/DirtyVisuals.cs
  32. 6
      tests/Avalonia.Markup.Xaml.UnitTests/Xaml/Style2.xaml

11
docs/tutorial/from-wpf.md

@ -73,17 +73,6 @@ and includes `DirectProperty` for turning standard CLR properties into Avalonia
properties. The common base class of `StyledProperty` and `DirectProperty` properties. The common base class of `StyledProperty` and `DirectProperty`
is `AvaloniaProperty`. is `AvaloniaProperty`.
# Resources
There is no `Resources` collection on controls in Avalonia, however `Style`s
do have a `Resources` collection for style-related resources. These can be
referred to using the `{StyleResource}` markup extension both inside and outside
styles.
For non-style-related resources, we suggest defining them in code and referring
to them in markup using the `{Static}` markup extension. To read more about the reasoning for this,
see [this issue comment](https://github.com/AvaloniaUI/Avalonia/issues/462#issuecomment-191849723).
## Grid ## Grid
Column and row definitions can be specified in Avalonia using strings, avoiding Column and row definitions can be specified in Avalonia using strings, avoiding

10
samples/ControlCatalog/Pages/BorderPage.xaml

@ -7,22 +7,22 @@
Margin="0,16,0,0" Margin="0,16,0,0"
HorizontalAlignment="Center" HorizontalAlignment="Center"
Gap="16"> Gap="16">
<Border BorderBrush="{StyleResource ThemeAccentBrush}" BorderThickness="2" Padding="16"> <Border BorderBrush="{DynamicResource ThemeAccentBrush}" BorderThickness="2" Padding="16">
<TextBlock>Border</TextBlock> <TextBlock>Border</TextBlock>
</Border> </Border>
<Border Background="{StyleResource ThemeAccentBrush2}" <Border Background="{DynamicResource ThemeAccentBrush2}"
BorderBrush="{StyleResource ThemeAccentBrush}" BorderBrush="{DynamicResource ThemeAccentBrush}"
BorderThickness="4" BorderThickness="4"
Padding="16"> Padding="16">
<TextBlock>Border and Background</TextBlock> <TextBlock>Border and Background</TextBlock>
</Border> </Border>
<Border BorderBrush="{StyleResource ThemeAccentBrush}" <Border BorderBrush="{DynamicResource ThemeAccentBrush}"
BorderThickness="4" BorderThickness="4"
CornerRadius="8" CornerRadius="8"
Padding="16"> Padding="16">
<TextBlock>Rounded Corners</TextBlock> <TextBlock>Rounded Corners</TextBlock>
</Border> </Border>
<Border Background="{StyleResource ThemeAccentBrush2}" <Border Background="{DynamicResource ThemeAccentBrush2}"
CornerRadius="8" CornerRadius="8"
Padding="16"> Padding="16">
<TextBlock>Rounded Corners</TextBlock> <TextBlock>Rounded Corners</TextBlock>

8
samples/ControlCatalog/Pages/ButtonPage.xaml

@ -11,7 +11,7 @@
<StackPanel Orientation="Vertical" Gap="8" Width="150"> <StackPanel Orientation="Vertical" Gap="8" Width="150">
<Button>Button</Button> <Button>Button</Button>
<Button Foreground="White">Foreground</Button> <Button Foreground="White">Foreground</Button>
<Button Background="{StyleResource ThemeAccentBrush}">Background</Button> <Button Background="{DynamicResource ThemeAccentBrush}">Background</Button>
<Button IsEnabled="False">Disabled</Button> <Button IsEnabled="False">Disabled</Button>
<Button Content="Re-themed"> <Button Content="Re-themed">
<Button.Styles> <Button.Styles>
@ -27,9 +27,9 @@
<StackPanel Orientation="Vertical" Gap="8" Width="150"> <StackPanel Orientation="Vertical" Gap="8" Width="150">
<Button BorderThickness="0">No Border</Button> <Button BorderThickness="0">No Border</Button>
<Button BorderBrush="{StyleResource ThemeAccentBrush}">Border Color</Button> <Button BorderBrush="{DynamicResource ThemeAccentBrush}">Border Color</Button>
<Button BorderBrush="{StyleResource ThemeAccentBrush}" BorderThickness="4">Thick Border</Button> <Button BorderBrush="{DynamicResource ThemeAccentBrush}" BorderThickness="4">Thick Border</Button>
<Button BorderBrush="{StyleResource ThemeAccentBrush}" BorderThickness="4" IsEnabled="False">Disabled</Button> <Button BorderBrush="{DynamicResource ThemeAccentBrush}" BorderThickness="4" IsEnabled="False">Disabled</Button>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>

2
samples/ControlCatalog/Pages/ContextMenuPage.xaml

@ -7,7 +7,7 @@
Margin="0,16,0,0" Margin="0,16,0,0"
HorizontalAlignment="Center" HorizontalAlignment="Center"
Gap="16"> Gap="16">
<Border Background="{StyleResource ThemeAccentBrush}" <Border Background="{DynamicResource ThemeAccentBrush}"
Padding="48,48,48,48"> Padding="48,48,48,48">
<Border.ContextMenu> <Border.ContextMenu>
<ContextMenu> <ContextMenu>

2
samples/ControlCatalog/Pages/DropDownPage.xaml

@ -14,7 +14,7 @@
<DropDown SelectedIndex="0"> <DropDown SelectedIndex="0">
<DropDownItem> <DropDownItem>
<Panel> <Panel>
<Rectangle Fill="{StyleResource ThemeAccentBrush}"/> <Rectangle Fill="{DynamicResource ThemeAccentBrush}"/>
<TextBlock Margin="8">Control Items</TextBlock> <TextBlock Margin="8">Control Items</TextBlock>
</Panel> </Panel>
</DropDownItem> </DropDownItem>

8
samples/ControlCatalog/Pages/LayoutTransformControlPage.xaml

@ -10,10 +10,10 @@
RowDefinitions="24,Auto,24" RowDefinitions="24,Auto,24"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center"> VerticalAlignment="Center">
<Border Background="{StyleResource ThemeAccentBrush}" Grid.Column="1" Grid.Row="0"/> <Border Background="{DynamicResource ThemeAccentBrush}" Grid.Column="1" Grid.Row="0"/>
<Border Background="{StyleResource ThemeAccentBrush}" Grid.Column="0" Grid.Row="1"/> <Border Background="{DynamicResource ThemeAccentBrush}" Grid.Column="0" Grid.Row="1"/>
<Border Background="{StyleResource ThemeAccentBrush}" Grid.Column="2" Grid.Row="1"/> <Border Background="{DynamicResource ThemeAccentBrush}" Grid.Column="2" Grid.Row="1"/>
<Border Background="{StyleResource ThemeAccentBrush}" Grid.Column="1" Grid.Row="2"/> <Border Background="{DynamicResource ThemeAccentBrush}" Grid.Column="1" Grid.Row="2"/>
<LayoutTransformControl Name="layoutTransform" Grid.Column="1" Grid.Row="1"> <LayoutTransformControl Name="layoutTransform" Grid.Column="1" Grid.Row="1">
<LayoutTransformControl.LayoutTransform> <LayoutTransformControl.LayoutTransform>

4
samples/ControlCatalog/SideBar.xaml

@ -3,7 +3,7 @@
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<DockPanel> <DockPanel>
<ScrollViewer MinWidth="190" Background="{StyleResource ThemeAccentBrush}" DockPanel.Dock="Left"> <ScrollViewer MinWidth="190" Background="{DynamicResource ThemeAccentBrush}" DockPanel.Dock="Left">
<TabStrip Name="PART_TabStrip" <TabStrip Name="PART_TabStrip"
MemberSelector="{Static TabControl.HeaderSelector}" MemberSelector="{Static TabControl.HeaderSelector}"
Items="{TemplateBinding Items}" Items="{TemplateBinding Items}"
@ -35,6 +35,6 @@
</Style> </Style>
<Style Selector="TabControl.sidebar TabStripItem:selected"> <Style Selector="TabControl.sidebar TabStripItem:selected">
<Setter Property="Background" Value="{StyleResource ThemeAccentBrush2}"/> <Setter Property="Background" Value="{DynamicResource ThemeAccentBrush2}"/>
</Style> </Style>
</Styles> </Styles>

2
samples/RenderTest/Pages/ClippingPage.xaml

@ -5,7 +5,7 @@
Width="100" Width="100"
Height="100" Height="100"
Clip="M 58.625 0.07421875 C 50.305778 0.26687364 42.411858 7.0346526 41.806641 15.595703 C 42.446442 22.063923 39.707425 13.710754 36.982422 12.683594 C 29.348395 6.1821635 16.419398 8.4359222 11.480469 17.195312 C 6.0935256 25.476803 9.8118851 37.71125 18.8125 41.6875 C 9.1554771 40.62945 -0.070876925 49.146842 0.21679688 58.857422 C 0.21545578 60.872512 0.56758794 62.88911 1.2617188 64.78125 C 4.3821886 74.16708 16.298268 78.921772 25.03125 74.326172 C 28.266843 72.062552 26.298191 74.214838 25.414062 76.398438 C 21.407348 85.589198 27.295992 97.294293 37.097656 99.501953 C 46.864883 102.3541 57.82177 94.726518 58.539062 84.580078 C 58.142158 79.498998 59.307538 83.392694 61.207031 85.433594 C 67.532324 93.056874 80.440232 93.192029 86.882812 85.630859 C 93.836392 78.456939 92.396838 65.538666 84.115234 60.009766 C 79.783641 57.904836 83.569793 58.802369 86.375 58.193359 C 96.383335 56.457569 102.87506 44.824101 99.083984 35.394531 C 95.963498 26.008711 84.047451 21.254079 75.314453 25.849609 C 72.078834 28.113269 74.047517 25.960974 74.931641 23.777344 C 78.93827 14.586564 73.049722 2.8815081 63.248047 0.67382812 C 61.721916 0.22817968 60.165597 0.038541919 58.625 0.07421875 z "> Clip="M 58.625 0.07421875 C 50.305778 0.26687364 42.411858 7.0346526 41.806641 15.595703 C 42.446442 22.063923 39.707425 13.710754 36.982422 12.683594 C 29.348395 6.1821635 16.419398 8.4359222 11.480469 17.195312 C 6.0935256 25.476803 9.8118851 37.71125 18.8125 41.6875 C 9.1554771 40.62945 -0.070876925 49.146842 0.21679688 58.857422 C 0.21545578 60.872512 0.56758794 62.88911 1.2617188 64.78125 C 4.3821886 74.16708 16.298268 78.921772 25.03125 74.326172 C 28.266843 72.062552 26.298191 74.214838 25.414062 76.398438 C 21.407348 85.589198 27.295992 97.294293 37.097656 99.501953 C 46.864883 102.3541 57.82177 94.726518 58.539062 84.580078 C 58.142158 79.498998 59.307538 83.392694 61.207031 85.433594 C 67.532324 93.056874 80.440232 93.192029 86.882812 85.630859 C 93.836392 78.456939 92.396838 65.538666 84.115234 60.009766 C 79.783641 57.904836 83.569793 58.802369 86.375 58.193359 C 96.383335 56.457569 102.87506 44.824101 99.083984 35.394531 C 95.963498 26.008711 84.047451 21.254079 75.314453 25.849609 C 72.078834 28.113269 74.047517 25.960974 74.931641 23.777344 C 78.93827 14.586564 73.049722 2.8815081 63.248047 0.67382812 C 61.721916 0.22817968 60.165597 0.038541919 58.625 0.07421875 z ">
<Border Name="clipChild" Background="{StyleResource ThemeAccentBrush}" Margin="4"> <Border Name="clipChild" Background="{DynamicResource ThemeAccentBrush}" Margin="4">
<!-- Setting opacity puts the TextBox on a new layer --> <!-- Setting opacity puts the TextBox on a new layer -->
<TextBox Text="Avalonia" Opacity="0.9" VerticalAlignment="Center"/> <TextBox Text="Avalonia" Opacity="0.9" VerticalAlignment="Center"/>
</Border> </Border>

8
samples/RenderTest/Pages/DrawingPage.xaml

@ -49,7 +49,7 @@
BorderThickness="1" BorderThickness="1"
BorderBrush="Gray" BorderBrush="Gray"
Margin="5"> Margin="5">
<DrawingPresenter Drawing="{StyleResource Bulb}" /> <DrawingPresenter Drawing="{DynamicResource Bulb}" />
</Border> </Border>
<TextBlock Text="Fill" <TextBlock Text="Fill"
Margin="3" Margin="3"
@ -61,7 +61,7 @@
BorderThickness="1" BorderThickness="1"
BorderBrush="Gray" BorderBrush="Gray"
Margin="5"> Margin="5">
<DrawingPresenter Drawing="{StyleResource Bulb}" <DrawingPresenter Drawing="{DynamicResource Bulb}"
Width="100" Width="100"
Height="50" Height="50"
Stretch="Fill" /> Stretch="Fill" />
@ -76,7 +76,7 @@
BorderThickness="1" BorderThickness="1"
BorderBrush="Gray" BorderBrush="Gray"
Margin="5"> Margin="5">
<DrawingPresenter Drawing="{StyleResource Bulb}" <DrawingPresenter Drawing="{DynamicResource Bulb}"
Width="100" Width="100"
Height="50" Height="50"
Stretch="Uniform" /> Stretch="Uniform" />
@ -91,7 +91,7 @@
BorderThickness="1" BorderThickness="1"
BorderBrush="Gray" BorderBrush="Gray"
Margin="5"> Margin="5">
<DrawingPresenter Drawing="{StyleResource Bulb}" <DrawingPresenter Drawing="{DynamicResource Bulb}"
Width="100" Width="100"
Height="50" Height="50"
Stretch="UniformToFill" /> Stretch="UniformToFill" />

4
samples/RenderTest/SideBar.xaml

@ -3,7 +3,7 @@
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<DockPanel> <DockPanel>
<ScrollViewer MinWidth="190" Background="{StyleResource ThemeAccentBrush}" DockPanel.Dock="Left"> <ScrollViewer MinWidth="190" Background="{DynamicResource ThemeAccentBrush}" DockPanel.Dock="Left">
<TabStrip Name="PART_TabStrip" <TabStrip Name="PART_TabStrip"
MemberSelector="{Static TabControl.HeaderSelector}" MemberSelector="{Static TabControl.HeaderSelector}"
Items="{TemplateBinding Items}" Items="{TemplateBinding Items}"
@ -35,6 +35,6 @@
</Style> </Style>
<Style Selector="TabControl.sidebar TabStripItem:selected"> <Style Selector="TabControl.sidebar TabStripItem:selected">
<Setter Property="Background" Value="{StyleResource ThemeAccentBrush2}"/> <Setter Property="Background" Value="{DynamicResource ThemeAccentBrush2}"/>
</Style> </Style>
</Styles> </Styles>

14
src/Avalonia.Themes.Default/Button.xaml

@ -1,9 +1,9 @@
<Styles xmlns="https://github.com/avaloniaui"> <Styles xmlns="https://github.com/avaloniaui">
<Style Selector="Button"> <Style Selector="Button">
<Setter Property="Background" Value="{StyleResource ThemeControlMidBrush}"/> <Setter Property="Background" Value="{DynamicResource ThemeControlMidBrush}"/>
<Setter Property="BorderBrush" Value="{StyleResource ThemeBorderLightBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderLightBrush}"/>
<Setter Property="BorderThickness" Value="{StyleResource ThemeBorderThickness}"/> <Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/>
<Setter Property="Foreground" Value="{StyleResource ThemeForegroundBrush}"/> <Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="4"/> <Setter Property="Padding" Value="4"/>
@ -23,12 +23,12 @@
</Setter> </Setter>
</Style> </Style>
<Style Selector="Button:pointerover /template/ ContentPresenter"> <Style Selector="Button:pointerover /template/ ContentPresenter">
<Setter Property="BorderBrush" Value="{StyleResource ThemeBorderMidBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/>
</Style> </Style>
<Style Selector="Button:pressed /template/ ContentPresenter"> <Style Selector="Button:pressed /template/ ContentPresenter">
<Setter Property="Background" Value="{StyleResource ThemeControlDarkBrush}"/> <Setter Property="Background" Value="{DynamicResource ThemeControlDarkBrush}"/>
</Style> </Style>
<Style Selector="Button:disabled"> <Style Selector="Button:disabled">
<Setter Property="Opacity" Value="{StyleResource ThemeDisabledOpacity}"/> <Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}"/>
</Style> </Style>
</Styles> </Styles>

10
src/Avalonia.Themes.Default/CheckBox.xaml

@ -1,8 +1,8 @@
<Styles xmlns="https://github.com/avaloniaui"> <Styles xmlns="https://github.com/avaloniaui">
<Style Selector="CheckBox"> <Style Selector="CheckBox">
<Setter Property="Background" Value="Transparent"/> <Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="{StyleResource ThemeBorderMidBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/>
<Setter Property="BorderThickness" Value="{StyleResource ThemeBorderThickness}"/> <Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Grid ColumnDefinitions="Auto,*" Background="{TemplateBinding Background}"> <Grid ColumnDefinitions="Auto,*" Background="{TemplateBinding Background}">
@ -13,7 +13,7 @@
Height="18" Height="18"
VerticalAlignment="Center"> VerticalAlignment="Center">
<Path Name="checkMark" <Path Name="checkMark"
Fill="{StyleResource HighlightBrush}" Fill="{DynamicResource HighlightBrush}"
Width="11" Width="11"
Height="10" Height="10"
Stretch="Uniform" Stretch="Uniform"
@ -32,7 +32,7 @@
</Setter> </Setter>
</Style> </Style>
<Style Selector="CheckBox:pointerover /template/ Border#border"> <Style Selector="CheckBox:pointerover /template/ Border#border">
<Setter Property="BorderBrush" Value="{StyleResource ThemeBorderDarkBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderDarkBrush}"/>
</Style> </Style>
<Style Selector="CheckBox /template/ Path#checkMark"> <Style Selector="CheckBox /template/ Path#checkMark">
<Setter Property="IsVisible" Value="False"/> <Setter Property="IsVisible" Value="False"/>
@ -41,6 +41,6 @@
<Setter Property="IsVisible" Value="True"/> <Setter Property="IsVisible" Value="True"/>
</Style> </Style>
<Style Selector="CheckBox:disabled /template/ Border#border"> <Style Selector="CheckBox:disabled /template/ Border#border">
<Setter Property="Opacity" Value="{StyleResource ThemeDisabledOpacity}"/> <Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}"/>
</Style> </Style>
</Styles> </Styles>

10
src/Avalonia.Themes.Default/DropDown.xaml

@ -1,7 +1,7 @@
<Styles xmlns="https://github.com/avaloniaui"> <Styles xmlns="https://github.com/avaloniaui">
<Style Selector="DropDown"> <Style Selector="DropDown">
<Setter Property="BorderBrush" Value="{StyleResource ThemeBorderMidBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/>
<Setter Property="BorderThickness" Value="{StyleResource ThemeBorderThickness}"/> <Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/>
<Setter Property="Padding" Value="4"/> <Setter Property="Padding" Value="4"/>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
@ -21,7 +21,7 @@
Focusable="False" Focusable="False"
IsChecked="{TemplateBinding IsDropDownOpen, Mode=TwoWay}" IsChecked="{TemplateBinding IsDropDownOpen, Mode=TwoWay}"
Grid.Column="1"> Grid.Column="1">
<Path Fill="{StyleResource ThemeForegroundBrush}" <Path Fill="{DynamicResource ThemeForegroundBrush}"
Width="8" Width="8"
Height="4" Height="4"
Stretch="Uniform" Stretch="Uniform"
@ -35,7 +35,7 @@
MaxHeight="{TemplateBinding MaxDropDownHeight}" MaxHeight="{TemplateBinding MaxDropDownHeight}"
PlacementTarget="{TemplateBinding}" PlacementTarget="{TemplateBinding}"
StaysOpen="False"> StaysOpen="False">
<Border BorderBrush="{StyleResource ThemeBorderMidBrush}" <Border BorderBrush="{DynamicResource ThemeBorderMidBrush}"
BorderThickness="1"> BorderThickness="1">
<ScrollViewer> <ScrollViewer>
<ItemsPresenter Name="PART_ItemsPresenter" <ItemsPresenter Name="PART_ItemsPresenter"
@ -51,6 +51,6 @@
</Setter> </Setter>
</Style> </Style>
<Style Selector="DropDown:pointerover /template/ Border#border"> <Style Selector="DropDown:pointerover /template/ Border#border">
<Setter Property="BorderBrush" Value="{StyleResource ThemeBorderDarkBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderDarkBrush}"/>
</Style> </Style>
</Styles> </Styles>

4
src/Avalonia.Themes.Default/EmbeddableControlRoot.xaml

@ -1,7 +1,7 @@
<Style xmlns="https://github.com/avaloniaui" Selector="EmbeddableControlRoot"> <Style xmlns="https://github.com/avaloniaui" Selector="EmbeddableControlRoot">
<Setter Property="Background" Value="{StyleResource ThemeBackgroundBrush}"/> <Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}"/>
<Setter Property="FontFamily" Value="Segoe UI"/> <Setter Property="FontFamily" Value="Segoe UI"/>
<Setter Property="FontSize" Value="{StyleResource FontSizeNormal}"/> <Setter Property="FontSize" Value="{DynamicResource FontSizeNormal}"/>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Border Background="{TemplateBinding Background}"> <Border Background="{TemplateBinding Background}">

8
src/Avalonia.Themes.Default/GridSplitter.xaml

@ -1,7 +1,7 @@
<Styles xmlns="https://github.com/avaloniaui"> <Styles xmlns="https://github.com/avaloniaui">
<Style Selector="GridSplitter:vertical"> <Style Selector="GridSplitter:vertical">
<Setter Property="Width" Value="6"/> <Setter Property="Width" Value="6"/>
<Setter Property="Background" Value="{StyleResource ThemeControlLightBrush}"/> <Setter Property="Background" Value="{DynamicResource ThemeControlLightBrush}"/>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Border Background="{TemplateBinding Background}"> <Border Background="{TemplateBinding Background}">
@ -11,7 +11,7 @@
<Setter Property="HorizontalAlignment" Value="Center"/> <Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Width" Value="4"/> <Setter Property="Width" Value="4"/>
<Setter Property="Height" Value="4"/> <Setter Property="Height" Value="4"/>
<Setter Property="Fill" Value="{StyleResource ThemeControlMidBrush}"/> <Setter Property="Fill" Value="{DynamicResource ThemeControlMidBrush}"/>
<Setter Property="Margin" Value="1"/> <Setter Property="Margin" Value="1"/>
</Style> </Style>
</StackPanel.Styles> </StackPanel.Styles>
@ -25,7 +25,7 @@
</Style> </Style>
<Style Selector="GridSplitter:horizontal"> <Style Selector="GridSplitter:horizontal">
<Setter Property="Height" Value="6"/> <Setter Property="Height" Value="6"/>
<Setter Property="Background" Value="{StyleResource ThemeControlLightBrush}"/> <Setter Property="Background" Value="{DynamicResource ThemeControlLightBrush}"/>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Border Background="{TemplateBinding Background}"> <Border Background="{TemplateBinding Background}">
@ -35,7 +35,7 @@
<Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Width" Value="4"/> <Setter Property="Width" Value="4"/>
<Setter Property="Height" Value="4"/> <Setter Property="Height" Value="4"/>
<Setter Property="Fill" Value="{StyleResource ThemeControlMidBrush}"/> <Setter Property="Fill" Value="{DynamicResource ThemeControlMidBrush}"/>
<Setter Property="Margin" Value="1"/> <Setter Property="Margin" Value="1"/>
</Style> </Style>
</StackPanel.Styles> </StackPanel.Styles>

6
src/Avalonia.Themes.Default/ListBox.xaml

@ -1,7 +1,7 @@
<Style xmlns="https://github.com/avaloniaui" Selector="ListBox"> <Style xmlns="https://github.com/avaloniaui" Selector="ListBox">
<Setter Property="Background" Value="{StyleResource ThemeBackgroundBrush}"/> <Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}"/>
<Setter Property="BorderBrush" Value="{StyleResource ThemeBorderMidBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/>
<Setter Property="BorderThickness" Value="{StyleResource ThemeBorderThickness}"/> <Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/>
<Setter Property="Padding" Value="4"/> <Setter Property="Padding" Value="4"/>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>

18
src/Avalonia.Themes.Default/MenuItem.xaml

@ -38,7 +38,7 @@
</ContentPresenter> </ContentPresenter>
<Path Name="rightArrow" <Path Name="rightArrow"
Data="M0,0L4,3.5 0,7z" Data="M0,0L4,3.5 0,7z"
Fill="{StyleResource ThemeForegroundBrush}" Fill="{DynamicResource ThemeForegroundBrush}"
Margin="10,0,0,0" Margin="10,0,0,0"
VerticalAlignment="Center" VerticalAlignment="Center"
Grid.Column="3"/> Grid.Column="3"/>
@ -47,7 +47,7 @@
StaysOpen="True" StaysOpen="True"
IsOpen="{TemplateBinding Path=IsSubMenuOpen, Mode=TwoWay}"> IsOpen="{TemplateBinding Path=IsSubMenuOpen, Mode=TwoWay}">
<Border Background="{TemplateBinding Background}" <Border Background="{TemplateBinding Background}"
BorderBrush="{StyleResource ThemeBorderMidBrush}" BorderBrush="{DynamicResource ThemeBorderMidBrush}"
BorderThickness="1"> BorderThickness="1">
<ScrollViewer> <ScrollViewer>
<Panel> <Panel>
@ -58,7 +58,7 @@
Margin="2" Margin="2"
MemberSelector="{TemplateBinding MemberSelector}"/> MemberSelector="{TemplateBinding MemberSelector}"/>
<Rectangle Name="iconSeparator" <Rectangle Name="iconSeparator"
Fill="{StyleResource ThemeControlMidBrush}" Fill="{DynamicResource ThemeControlMidBrush}"
HorizontalAlignment="Left" HorizontalAlignment="Left"
IsHitTestVisible="False" IsHitTestVisible="False"
Margin="29,2,0,2" Margin="29,2,0,2"
@ -94,7 +94,7 @@
IsOpen="{TemplateBinding Path=IsSubMenuOpen, Mode=TwoWay}" IsOpen="{TemplateBinding Path=IsSubMenuOpen, Mode=TwoWay}"
StaysOpen="True"> StaysOpen="True">
<Border Background="{TemplateBinding Background}" <Border Background="{TemplateBinding Background}"
BorderBrush="{StyleResource ThemeBorderMidBrush}" BorderBrush="{DynamicResource ThemeBorderMidBrush}"
BorderThickness="1"> BorderThickness="1">
<ScrollViewer> <ScrollViewer>
<Panel> <Panel>
@ -105,7 +105,7 @@
Margin="2" Margin="2"
MemberSelector="{TemplateBinding MemberSelector}"/> MemberSelector="{TemplateBinding MemberSelector}"/>
<Rectangle Name="iconSeparator" <Rectangle Name="iconSeparator"
Fill="{StyleResource ThemeControlMidBrush}" Fill="{DynamicResource ThemeControlMidBrush}"
HorizontalAlignment="Left" HorizontalAlignment="Left"
IsHitTestVisible="False" IsHitTestVisible="False"
Margin="29,2,0,2" Margin="29,2,0,2"
@ -121,13 +121,13 @@
</Style> </Style>
<Style Selector="MenuItem:selected /template/ Border#root"> <Style Selector="MenuItem:selected /template/ Border#root">
<Setter Property="Background" Value="{StyleResource ThemeAccentBrush4}"/> <Setter Property="Background" Value="{DynamicResource ThemeAccentBrush4}"/>
<Setter Property="BorderBrush" Value="{StyleResource ThemeAccentBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ThemeAccentBrush}"/>
</Style> </Style>
<Style Selector="MenuItem:pointerover /template/ Border#root"> <Style Selector="MenuItem:pointerover /template/ Border#root">
<Setter Property="Background" Value="{StyleResource ThemeAccentBrush4}"/> <Setter Property="Background" Value="{DynamicResource ThemeAccentBrush4}"/>
<Setter Property="BorderBrush" Value="{StyleResource ThemeAccentBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ThemeAccentBrush}"/>
</Style> </Style>
<Style Selector="MenuItem:empty /template/ Path#rightArrow"> <Style Selector="MenuItem:empty /template/ Path#rightArrow">

2
src/Avalonia.Themes.Default/PopupRoot.xaml

@ -1,5 +1,5 @@
<Style xmlns="https://github.com/avaloniaui" Selector="PopupRoot"> <Style xmlns="https://github.com/avaloniaui" Selector="PopupRoot">
<Setter Property="Background" Value="{StyleResource ThemeBackgroundBrush}"/> <Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}"/>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<ContentPresenter Name="PART_ContentPresenter" <ContentPresenter Name="PART_ContentPresenter"

4
src/Avalonia.Themes.Default/ProgressBar.xaml

@ -1,6 +1,6 @@
<Style xmlns="https://github.com/avaloniaui" Selector="ProgressBar"> <Style xmlns="https://github.com/avaloniaui" Selector="ProgressBar">
<Setter Property="Background" Value="{StyleResource ThemeAccentBrush4}"/> <Setter Property="Background" Value="{DynamicResource ThemeAccentBrush4}"/>
<Setter Property="Foreground" Value="{StyleResource ThemeAccentBrush}"/> <Setter Property="Foreground" Value="{DynamicResource ThemeAccentBrush}"/>
<Setter Property="MinHeight" Value="14"/> <Setter Property="MinHeight" Value="14"/>
<Setter Property="MinWidth" Value="200"/> <Setter Property="MinWidth" Value="200"/>
<Setter Property="Template"> <Setter Property="Template">

10
src/Avalonia.Themes.Default/RadioButton.xaml

@ -1,8 +1,8 @@
<Styles xmlns="https://github.com/avaloniaui"> <Styles xmlns="https://github.com/avaloniaui">
<Style Selector="RadioButton"> <Style Selector="RadioButton">
<Setter Property="Background" Value="Transparent"/> <Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="{StyleResource ThemeBorderMidBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/>
<Setter Property="BorderThickness" Value="{StyleResource ThemeBorderThickness}"/> <Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Grid ColumnDefinitions="Auto,*" Background="{TemplateBinding Background}"> <Grid ColumnDefinitions="Auto,*" Background="{TemplateBinding Background}">
@ -13,7 +13,7 @@
Height="18" Height="18"
VerticalAlignment="Center"/> VerticalAlignment="Center"/>
<Ellipse Name="checkMark" <Ellipse Name="checkMark"
Fill="{StyleResource HighlightBrush}" Fill="{DynamicResource HighlightBrush}"
Width="10" Width="10"
Height="10" Height="10"
Stretch="Uniform" Stretch="Uniform"
@ -31,7 +31,7 @@
</Setter> </Setter>
</Style> </Style>
<Style Selector="RadioButton:pointerover /template/ Ellipse#border"> <Style Selector="RadioButton:pointerover /template/ Ellipse#border">
<Setter Property="Stroke" Value="{StyleResource ThemeBorderDarkBrush}"/> <Setter Property="Stroke" Value="{DynamicResource ThemeBorderDarkBrush}"/>
</Style> </Style>
<Style Selector="RadioButton /template/ Ellipse#checkMark"> <Style Selector="RadioButton /template/ Ellipse#checkMark">
<Setter Property="IsVisible" Value="False"/> <Setter Property="IsVisible" Value="False"/>
@ -40,6 +40,6 @@
<Setter Property="IsVisible" Value="True"/> <Setter Property="IsVisible" Value="True"/>
</Style> </Style>
<Style Selector="RadioButton:disabled /template/ Ellipse#border"> <Style Selector="RadioButton:disabled /template/ Ellipse#border">
<Setter Property="Opacity" Value="{StyleResource ThemeDisabledOpacity}"/> <Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}"/>
</Style> </Style>
</Styles> </Styles>

8
src/Avalonia.Themes.Default/ScrollBar.xaml

@ -2,7 +2,7 @@
<Style Selector="ScrollBar"> <Style Selector="ScrollBar">
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Border Background="{StyleResource ThemeControlMidBrush}"> <Border Background="{DynamicResource ThemeControlMidBrush}">
<Grid RowDefinitions="10,*,10"> <Grid RowDefinitions="10,*,10">
<RepeatButton Name="PART_LineUpButton" <RepeatButton Name="PART_LineUpButton"
Classes="repeat" Classes="repeat"
@ -30,7 +30,7 @@
<Thumb Name="thumb"> <Thumb Name="thumb">
<Thumb.Template> <Thumb.Template>
<ControlTemplate> <ControlTemplate>
<Border Background="{StyleResource ThemeControlDarkBrush}" /> <Border Background="{DynamicResource ThemeControlDarkBrush}" />
</ControlTemplate> </ControlTemplate>
</Thumb.Template> </Thumb.Template>
</Thumb> </Thumb>
@ -53,7 +53,7 @@
Value="10" /> Value="10" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Border Background="{StyleResource ThemeControlMidBrush}"> <Border Background="{DynamicResource ThemeControlMidBrush}">
<Grid ColumnDefinitions="10,*,10"> <Grid ColumnDefinitions="10,*,10">
<RepeatButton Name="PART_LineUpButton" <RepeatButton Name="PART_LineUpButton"
Classes="repeat" Classes="repeat"
@ -81,7 +81,7 @@
<Thumb Name="thumb"> <Thumb Name="thumb">
<Thumb.Template> <Thumb.Template>
<ControlTemplate> <ControlTemplate>
<Border Background="{StyleResource ThemeControlDarkBrush}" /> <Border Background="{DynamicResource ThemeControlDarkBrush}" />
</ControlTemplate> </ControlTemplate>
</Thumb.Template> </Thumb.Template>
</Thumb> </Thumb>

4
src/Avalonia.Themes.Default/Separator.xaml

@ -11,13 +11,13 @@
</Style> </Style>
<Style Selector="MenuItem > Separator"> <Style Selector="MenuItem > Separator">
<Setter Property="Background" Value="{StyleResource ThemeControlMidBrush}"/> <Setter Property="Background" Value="{DynamicResource ThemeControlMidBrush}"/>
<Setter Property="Margin" Value="29,1,0,1"/> <Setter Property="Margin" Value="29,1,0,1"/>
<Setter Property="Height" Value="1"/> <Setter Property="Height" Value="1"/>
</Style> </Style>
<Style Selector="ContextMenu > Separator"> <Style Selector="ContextMenu > Separator">
<Setter Property="Background" Value="{StyleResource ThemeControlMidBrush}"/> <Setter Property="Background" Value="{DynamicResource ThemeControlMidBrush}"/>
<Setter Property="Margin" Value="29,1,0,1"/> <Setter Property="Margin" Value="29,1,0,1"/>
<Setter Property="Height" Value="1"/> <Setter Property="Height" Value="1"/>
</Style> </Style>

6
src/Avalonia.Themes.Default/Slider.xaml

@ -24,7 +24,7 @@
<Thumb.Template> <Thumb.Template>
<ControlTemplate> <ControlTemplate>
<Grid> <Grid>
<Ellipse Width="12" Height="12" Fill="{StyleResource ThemeAccentBrush}"/> <Ellipse Width="12" Height="12" Fill="{DynamicResource ThemeAccentBrush}"/>
</Grid> </Grid>
</ControlTemplate> </ControlTemplate>
</Thumb.Template> </Thumb.Template>
@ -59,7 +59,7 @@
<Thumb.Template> <Thumb.Template>
<ControlTemplate> <ControlTemplate>
<Grid> <Grid>
<Ellipse Width="12" Height="12" Fill="{StyleResource ThemeAccentBrush}"/> <Ellipse Width="12" Height="12" Fill="{DynamicResource ThemeAccentBrush}"/>
</Grid> </Grid>
</ControlTemplate> </ControlTemplate>
</Thumb.Template> </Thumb.Template>
@ -77,7 +77,7 @@
</Style> </Style>
<Style Selector="Slider /template/ Border#TrackBackground"> <Style Selector="Slider /template/ Border#TrackBackground">
<Setter Property="BorderThickness" Value="2"/> <Setter Property="BorderThickness" Value="2"/>
<Setter Property="BorderBrush" Value="{StyleResource ThemeBorderLightBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderLightBrush}"/>
</Style> </Style>
<Style Selector="Slider /template/ RepeatButton.repeattrack"> <Style Selector="Slider /template/ RepeatButton.repeattrack">
<Setter Property="Background" Value="Transparent"/> <Setter Property="Background" Value="Transparent"/>

6
src/Avalonia.Themes.Default/TabStripItem.xaml

@ -1,8 +1,8 @@
<Styles xmlns="https://github.com/avaloniaui"> <Styles xmlns="https://github.com/avaloniaui">
<Style Selector="TabStripItem"> <Style Selector="TabStripItem">
<Setter Property="Background" Value="Transparent"/> <Setter Property="Background" Value="Transparent"/>
<Setter Property="FontSize" Value="{StyleResource FontSizeLarge}"/> <Setter Property="FontSize" Value="{DynamicResource FontSizeLarge}"/>
<Setter Property="Foreground" Value="{StyleResource ThemeForegroundLightBrush}"/> <Setter Property="Foreground" Value="{DynamicResource ThemeForegroundLightBrush}"/>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<ContentPresenter Name="PART_ContentPresenter" <ContentPresenter Name="PART_ContentPresenter"
@ -16,6 +16,6 @@
</Setter> </Setter>
</Style> </Style>
<Style Selector="TabStripItem:selected"> <Style Selector="TabStripItem:selected">
<Setter Property="Foreground" Value="{StyleResource ThemeForegroundBrush}"/> <Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}"/>
</Style> </Style>
</Styles> </Styles>

22
src/Avalonia.Themes.Default/TextBox.xaml

@ -1,8 +1,8 @@
<Styles xmlns="https://github.com/avaloniaui"> <Styles xmlns="https://github.com/avaloniaui">
<Style Selector="TextBox"> <Style Selector="TextBox">
<Setter Property="Background" Value="{StyleResource ThemeBackgroundBrush}"/> <Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}"/>
<Setter Property="BorderBrush" Value="{StyleResource ThemeBorderMidBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/>
<Setter Property="BorderThickness" Value="{StyleResource ThemeBorderThickness}"/> <Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/>
<Setter Property="Padding" Value="4"/> <Setter Property="Padding" Value="4"/>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
@ -13,8 +13,8 @@
<DockPanel Margin="{TemplateBinding Padding}"> <DockPanel Margin="{TemplateBinding Padding}">
<TextBlock Name="floatingWatermark" <TextBlock Name="floatingWatermark"
Foreground="{StyleResource ThemeAccentBrush}" Foreground="{DynamicResource ThemeAccentBrush}"
FontSize="{StyleResource FontSizeSmall}" FontSize="{DynamicResource FontSizeSmall}"
Text="{TemplateBinding Watermark}" Text="{TemplateBinding Watermark}"
DockPanel.Dock="Top"> DockPanel.Dock="Top">
<TextBlock.IsVisible> <TextBlock.IsVisible>
@ -33,7 +33,7 @@
<ToolTip.Tip> <ToolTip.Tip>
<ItemsControl Items="{TemplateBinding DataValidationErrors}" MemberSelector="Message"/> <ItemsControl Items="{TemplateBinding DataValidationErrors}" MemberSelector="Message"/>
</ToolTip.Tip> </ToolTip.Tip>
<Path Data="M14,7 A7,7 0 0,0 0,7 M0,7 A7,7 0 1,0 14,7 M7,3l0,5 M7,9l0,2" Stroke="{StyleResource ErrorBrush}" StrokeThickness="2"/> <Path Data="M14,7 A7,7 0 0,0 0,7 M0,7 A7,7 0 1,0 14,7 M7,3l0,5 M7,9l0,2" Stroke="{DynamicResource ErrorBrush}" StrokeThickness="2"/>
</Canvas> </Canvas>
<ScrollViewer CanScrollHorizontally="{TemplateBinding CanScrollHorizontally}" <ScrollViewer CanScrollHorizontally="{TemplateBinding CanScrollHorizontally}"
@ -62,13 +62,13 @@
</Setter> </Setter>
</Style> </Style>
<Style Selector="TextBox:pointerover /template/ Border#border"> <Style Selector="TextBox:pointerover /template/ Border#border">
<Setter Property="BorderBrush" Value="{StyleResource ThemeBorderDarkBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderDarkBrush}"/>
</Style> </Style>
<Style Selector="TextBox:focus /template/ Border#border"> <Style Selector="TextBox:focus /template/ Border#border">
<Setter Property="BorderBrush" Value="{StyleResource ThemeBorderDarkBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderDarkBrush}"/>
</Style> </Style>
<Style Selector="TextBox:error /template/ Border#border"> <Style Selector="TextBox:error /template/ Border#border">
<Setter Property="BorderBrush" Value="{StyleResource ErrorBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ErrorBrush}"/>
</Style> </Style>
<Style Selector="TextBox /template/ Canvas#error"> <Style Selector="TextBox /template/ Canvas#error">
<Setter Property="IsVisible" Value="False"/> <Setter Property="IsVisible" Value="False"/>
@ -77,7 +77,7 @@
<Setter Property="IsVisible" Value="True"/> <Setter Property="IsVisible" Value="True"/>
</Style> </Style>
<Style Selector="TextBox /template/ ToolTip"> <Style Selector="TextBox /template/ ToolTip">
<Setter Property="Background" Value="{StyleResource ErrorBrushLight}"/> <Setter Property="Background" Value="{DynamicResource ErrorBrushLight}"/>
<Setter Property="BorderBrush" Value="{StyleResource ErrorBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ErrorBrush}"/>
</Style> </Style>
</Styles> </Styles>

18
src/Avalonia.Themes.Default/ToggleButton.xaml

@ -1,9 +1,9 @@
<Styles xmlns="https://github.com/avaloniaui"> <Styles xmlns="https://github.com/avaloniaui">
<Style Selector="ToggleButton"> <Style Selector="ToggleButton">
<Setter Property="Background" Value="{StyleResource ThemeControlMidBrush}"/> <Setter Property="Background" Value="{DynamicResource ThemeControlMidBrush}"/>
<Setter Property="BorderBrush" Value="{StyleResource ThemeBorderLightBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderLightBrush}"/>
<Setter Property="BorderThickness" Value="{StyleResource ThemeBorderThickness}"/> <Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/>
<Setter Property="Foreground" Value="{StyleResource ThemeForegroundBrush}"/> <Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}"/>
<Setter Property="Padding" Value="4"/> <Setter Property="Padding" Value="4"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/>
@ -23,16 +23,16 @@
</Setter> </Setter>
</Style> </Style>
<Style Selector="ToggleButton:checked /template/ ContentPresenter"> <Style Selector="ToggleButton:checked /template/ ContentPresenter">
<Setter Property="Background" Value="{StyleResource ThemeControlDarkBrush}"/> <Setter Property="Background" Value="{DynamicResource ThemeControlDarkBrush}"/>
<Setter Property="BorderBrush" Value="{StyleResource ThemeBorderMidBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/>
</Style> </Style>
<Style Selector="ToggleButton:pointerover /template/ ContentPresenter"> <Style Selector="ToggleButton:pointerover /template/ ContentPresenter">
<Setter Property="BorderBrush" Value="{StyleResource ThemeBorderMidBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/>
</Style> </Style>
<Style Selector="ToggleButton:pressed /template/ ContentPresenter"> <Style Selector="ToggleButton:pressed /template/ ContentPresenter">
<Setter Property="Background" Value="{StyleResource ThemeControlDarkBrush}"/> <Setter Property="Background" Value="{DynamicResource ThemeControlDarkBrush}"/>
</Style> </Style>
<Style Selector="ToggleButton:disabled"> <Style Selector="ToggleButton:disabled">
<Setter Property="Opacity" Value="{StyleResource ThemeDisabledOpacity}"/> <Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}"/>
</Style> </Style>
</Styles> </Styles>

6
src/Avalonia.Themes.Default/ToolTip.xaml

@ -1,7 +1,7 @@
<Style xmlns="https://github.com/avaloniaui" Selector="ToolTip"> <Style xmlns="https://github.com/avaloniaui" Selector="ToolTip">
<Setter Property="Background" Value="{StyleResource ThemeBackgroundBrush}"/> <Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}"/>
<Setter Property="BorderBrush" Value="{StyleResource ThemeBorderMidBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/>
<Setter Property="BorderThickness" Value="{StyleResource ThemeBorderThickness}"/> <Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/>
<Setter Property="Padding" Value="4,2"/> <Setter Property="Padding" Value="4,2"/>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>

4
src/Avalonia.Themes.Default/TreeView.xaml

@ -1,7 +1,7 @@
<Style xmlns="https://github.com/avaloniaui" Selector="TreeView"> <Style xmlns="https://github.com/avaloniaui" Selector="TreeView">
<Setter Property="Background" Value="Transparent"/> <Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="{StyleResource ThemeBorderMidBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/>
<Setter Property="BorderThickness" Value="{StyleResource ThemeBorderThickness}"/> <Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/>
<Setter Property="Padding" Value="4"/> <Setter Property="Padding" Value="4"/>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>

2
src/Avalonia.Themes.Default/TreeViewItem.xaml

@ -36,7 +36,7 @@
Height="12" Height="12"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center"> VerticalAlignment="Center">
<Path Fill="{StyleResource ThemeForegroundBrush}" <Path Fill="{DynamicResource ThemeForegroundBrush}"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
Data="M 0 2 L 4 6 L 0 10 Z"/> Data="M 0 2 L 4 6 L 0 10 Z"/>

4
src/Avalonia.Themes.Default/Window.xaml

@ -1,7 +1,7 @@
<Style xmlns="https://github.com/avaloniaui" Selector="Window"> <Style xmlns="https://github.com/avaloniaui" Selector="Window">
<Setter Property="Background" Value="{StyleResource ThemeBackgroundBrush}"/> <Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}"/>
<Setter Property="FontFamily" Value="Segoe UI"/> <Setter Property="FontFamily" Value="Segoe UI"/>
<Setter Property="FontSize" Value="{StyleResource FontSizeNormal}"/> <Setter Property="FontSize" Value="{DynamicResource FontSizeNormal}"/>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Border Background="{TemplateBinding Background}"> <Border Background="{TemplateBinding Background}">

68
src/Avalonia.Visuals/Rendering/DirtyVisuals.cs

@ -17,6 +17,8 @@ namespace Avalonia.Rendering
{ {
private SortedDictionary<int, List<IVisual>> _inner = new SortedDictionary<int, List<IVisual>>(); private SortedDictionary<int, List<IVisual>> _inner = new SortedDictionary<int, List<IVisual>>();
private Dictionary<IVisual, int> _index = new Dictionary<IVisual, int>(); private Dictionary<IVisual, int> _index = new Dictionary<IVisual, int>();
private List<IVisual> _deferredChanges = new List<IVisual>();
private int _deferring;
/// <summary> /// <summary>
/// Gets the number of dirty visuals. /// Gets the number of dirty visuals.
@ -29,10 +31,15 @@ namespace Avalonia.Rendering
/// <param name="visual">The dirty visual.</param> /// <param name="visual">The dirty visual.</param>
public void Add(IVisual visual) public void Add(IVisual visual)
{ {
if (_deferring > 0)
{
_deferredChanges.Add(visual);
return;
}
var distance = visual.CalculateDistanceFromAncestor(visual.VisualRoot); var distance = visual.CalculateDistanceFromAncestor(visual.VisualRoot);
int existingDistance;
if (_index.TryGetValue(visual, out existingDistance)) if (_index.TryGetValue(visual, out var existingDistance))
{ {
if (distance == existingDistance) if (distance == existingDistance)
{ {
@ -43,9 +50,7 @@ namespace Avalonia.Rendering
_index.Remove(visual); _index.Remove(visual);
} }
List<IVisual> list; if (!_inner.TryGetValue(distance, out var list))
if (!_inner.TryGetValue(distance, out list))
{ {
list = new List<IVisual>(); list = new List<IVisual>();
_inner.Add(distance, list); _inner.Add(distance, list);
@ -60,27 +65,13 @@ namespace Avalonia.Rendering
/// </summary> /// </summary>
public void Clear() public void Clear()
{ {
_inner.Clear(); if (_deferring > 0)
_index.Clear();
}
/// <summary>
/// Removes a visual from the dirty list.
/// </summary>
/// <param name="visual">The visual.</param>
/// <returns>True if the visual was present in the list; otherwise false.</returns>
public bool Remove(IVisual visual)
{
int distance;
if (_index.TryGetValue(visual, out distance))
{ {
_inner[distance].Remove(visual); throw new InvalidOperationException("Cannot clear while enumerating");
_index.Remove(visual);
return true;
} }
return false; _inner.Clear();
_index.Clear();
} }
/// <summary> /// <summary>
@ -89,13 +80,38 @@ namespace Avalonia.Rendering
/// <returns>A collection of visuals.</returns> /// <returns>A collection of visuals.</returns>
public IEnumerator<IVisual> GetEnumerator() public IEnumerator<IVisual> GetEnumerator()
{ {
foreach (var i in _inner) BeginDefer();
try
{ {
foreach (var j in i.Value) foreach (var i in _inner)
{ {
yield return j; foreach (var j in i.Value)
{
yield return j;
}
} }
} }
finally
{
EndDefer();
}
}
private void BeginDefer()
{
++_deferring;
}
private void EndDefer()
{
if (--_deferring > 0) return;
foreach (var visual in _deferredChanges)
{
Add(visual);
}
_deferredChanges.Clear();
} }
/// <summary> /// <summary>

6
tests/Avalonia.Markup.Xaml.UnitTests/Xaml/Style2.xaml

@ -1,8 +1,8 @@
<Style xmlns="https://github.com/avaloniaui" <Style xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style.Resources> <Style.Resources>
<SolidColorBrush x:Key="RedBrush" Color="{StyleResource Red}"/> <SolidColorBrush x:Key="RedBrush" Color="{DynamicResource Red}"/>
<SolidColorBrush x:Key="GreenBrush" Color="{StyleResource Green}"/> <SolidColorBrush x:Key="GreenBrush" Color="{DynamicResource Green}"/>
<SolidColorBrush x:Key="BlueBrush" Color="{StyleResource Blue}"/> <SolidColorBrush x:Key="BlueBrush" Color="{DynamicResource Blue}"/>
</Style.Resources> </Style.Resources>
</Style> </Style>
Loading…
Cancel
Save