Browse Source

Merge branch 'new-animations-algo' of github.com:AvaloniaUI/Avalonia into new-animations-algo

pull/1793/head
Jumar Macato 8 years ago
parent
commit
b848fdd2bb
No known key found for this signature in database GPG Key ID: B19884DAC3A5BF3F
  1. 2
      samples/ControlCatalog/ControlCatalog.csproj
  2. 3
      samples/ControlCatalog/MainView.xaml
  3. 13
      samples/ControlCatalog/Pages/ListBoxPage.xaml
  4. 25
      samples/ControlCatalog/Pages/ListBoxPage.xaml.cs
  5. 4
      samples/ControlCatalog/Pages/NumericUpDownPage.xaml
  6. 8
      samples/ControlCatalog/Pages/ScreenPage.cs
  7. 2
      src/Avalonia.Controls/ContentControl.cs
  8. 32
      src/Avalonia.Controls/Converters/MarginMultiplierConverter.cs
  9. 42
      src/Avalonia.Controls/TreeView.cs
  10. 36
      src/Avalonia.Controls/TreeViewItem.cs
  11. 6
      src/Avalonia.Styling/Styling/PropertyEqualsSelector.cs
  12. 74
      src/Avalonia.Themes.Default/Accents/BaseLight.xaml
  13. 6
      src/Avalonia.Themes.Default/AutoCompleteBox.xaml
  14. 5
      src/Avalonia.Themes.Default/CalendarButton.xaml
  15. 6
      src/Avalonia.Themes.Default/CalendarDayButton.xaml
  16. 4
      src/Avalonia.Themes.Default/CalendarItem.xaml
  17. 5
      src/Avalonia.Themes.Default/CheckBox.xaml
  18. 6
      src/Avalonia.Themes.Default/DataValidationErrors.xaml
  19. 35
      src/Avalonia.Themes.Default/DatePicker.xaml
  20. 22
      src/Avalonia.Themes.Default/DropDownItem.xaml
  21. 4
      src/Avalonia.Themes.Default/Expander.xaml
  22. 23
      src/Avalonia.Themes.Default/ListBoxItem.xaml
  23. 10
      src/Avalonia.Themes.Default/ScrollBar.xaml
  24. 3
      src/Avalonia.Themes.Default/Slider.xaml
  25. 155
      src/Avalonia.Themes.Default/TreeViewItem.xaml
  26. 2
      src/Avalonia.Visuals/Media/Typeface.cs
  27. 33
      tests/Avalonia.Controls.UnitTests/TreeViewTests.cs

2
samples/ControlCatalog/ControlCatalog.csproj

@ -35,4 +35,4 @@
</ItemGroup> </ItemGroup>
<Import Project="..\..\build\Serilog.props" /> <Import Project="..\..\build\Serilog.props" />
</Project> </Project>

3
samples/ControlCatalog/MainView.xaml

@ -20,8 +20,9 @@
<TabItem Header="Expander"><pages:ExpanderPage/></TabItem> <TabItem Header="Expander"><pages:ExpanderPage/></TabItem>
<TabItem Header="Image"><pages:ImagePage/></TabItem> <TabItem Header="Image"><pages:ImagePage/></TabItem>
<TabItem Header="LayoutTransformControl"><pages:LayoutTransformControlPage/></TabItem> <TabItem Header="LayoutTransformControl"><pages:LayoutTransformControlPage/></TabItem>
<TabItem Header="ListBox"><pages:ListBoxPage/></TabItem>
<TabItem Header="Menu"><pages:MenuPage/></TabItem> <TabItem Header="Menu"><pages:MenuPage/></TabItem>
<TabItem Header="NumericUpDown"><pages:NumericUpDownPage/></TabItem> <TabItem Header="NumericUpDown"><pages:NumericUpDownPage/></TabItem>
<TabItem Header="ProgressBar"><pages:ProgressBarPage/></TabItem> <TabItem Header="ProgressBar"><pages:ProgressBarPage/></TabItem>
<TabItem Header="RadioButton"><pages:RadioButtonPage/></TabItem> <TabItem Header="RadioButton"><pages:RadioButtonPage/></TabItem>
<TabItem Header="Slider"><pages:SliderPage/></TabItem> <TabItem Header="Slider"><pages:SliderPage/></TabItem>

13
samples/ControlCatalog/Pages/ListBoxPage.xaml

@ -0,0 +1,13 @@
<UserControl xmlns="https://github.com/avaloniaui">
<StackPanel Orientation="Vertical" Spacing="4">
<TextBlock Classes="h1">ListBox</TextBlock>
<TextBlock Classes="h2">Hosts a collection of ListBoxItem.</TextBlock>
<StackPanel Orientation="Horizontal"
Margin="0,16,0,0"
HorizontalAlignment="Center"
Spacing="16">
<ListBox Items="{Binding}" Width="250" Height="350"></ListBox>
</StackPanel>
</StackPanel>
</UserControl>

25
samples/ControlCatalog/Pages/ListBoxPage.xaml.cs

@ -0,0 +1,25 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace ControlCatalog.Pages
{
public class ListBoxPage : UserControl
{
public ListBoxPage()
{
this.InitializeComponent();
DataContext = Enumerable.Range(1, 10).Select(i => $"Item {i}" )
.ToArray();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
}

4
samples/ControlCatalog/Pages/NumericUpDownPage.xaml

@ -14,7 +14,7 @@
<CheckBox Grid.Row="1" Grid.Column="1" IsChecked="{Binding #upDown.IsReadOnly}" VerticalAlignment="Center" Margin="2"/> <CheckBox Grid.Row="1" Grid.Column="1" IsChecked="{Binding #upDown.IsReadOnly}" VerticalAlignment="Center" Margin="2"/>
<TextBlock Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Margin="2">AllowSpin:</TextBlock> <TextBlock Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Margin="2">AllowSpin:</TextBlock>
<CheckBox Grid.Row="2" Grid.Column="1" IsChecked="{Binding #upDown.AllowSpin}" IsEnabled="{Binding #upDown.!IsReadOnly}" VerticalAlignment="Center" Margin="2"/> <CheckBox Grid.Row="2" Grid.Column="1" IsChecked="{Binding #upDown.AllowSpin}" VerticalAlignment="Center" Margin="2"/>
<TextBlock Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" Margin="2">ClipValueToMinMax:</TextBlock> <TextBlock Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" Margin="2">ClipValueToMinMax:</TextBlock>
<CheckBox Grid.Row="3" Grid.Column="1" IsChecked="{Binding #upDown.ClipValueToMinMax}" VerticalAlignment="Center" Margin="2"/> <CheckBox Grid.Row="3" Grid.Column="1" IsChecked="{Binding #upDown.ClipValueToMinMax}" VerticalAlignment="Center" Margin="2"/>
@ -77,4 +77,4 @@
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</UserControl> </UserControl>

8
samples/ControlCatalog/Pages/ScreenPage.cs

@ -42,7 +42,11 @@ namespace ControlCatalog.Pages
context.DrawRectangle(p, boundsRect); context.DrawRectangle(p, boundsRect);
context.DrawRectangle(p, workingAreaRect); context.DrawRectangle(p, workingAreaRect);
FormattedText text = new FormattedText(); FormattedText text = new FormattedText()
{
Typeface = Typeface.Default
};
text.Text = $"Bounds: {screen.Bounds.Width}:{screen.Bounds.Height}"; text.Text = $"Bounds: {screen.Bounds.Width}:{screen.Bounds.Height}";
context.DrawText(Brushes.Black, boundsRect.Position.WithY(boundsRect.Size.Height), text); context.DrawText(Brushes.Black, boundsRect.Position.WithY(boundsRect.Size.Height), text);
@ -59,4 +63,4 @@ namespace ControlCatalog.Pages
context.DrawRectangle(p, new Rect(w.Position.X / 10f + Math.Abs(_leftMost), w.Position.Y / 10, w.Bounds.Width / 10, w.Bounds.Height / 10)); context.DrawRectangle(p, new Rect(w.Position.X / 10f + Math.Abs(_leftMost), w.Position.Y / 10, w.Bounds.Width / 10, w.Bounds.Height / 10));
} }
} }
} }

2
src/Avalonia.Controls/ContentControl.cs

@ -45,6 +45,8 @@ namespace Avalonia.Controls
static ContentControl() static ContentControl()
{ {
ContentControlMixin.Attach<ContentControl>(ContentProperty, x => x.LogicalChildren); ContentControlMixin.Attach<ContentControl>(ContentProperty, x => x.LogicalChildren);
PseudoClass(ContentProperty, x => x != null, ":valid");
PseudoClass(ContentProperty, x => x == null, ":invalid");
} }
/// <summary> /// <summary>

32
src/Avalonia.Controls/Converters/MarginMultiplierConverter.cs

@ -0,0 +1,32 @@
using System;
using System.Globalization;
using Avalonia.Data.Converters;
namespace Avalonia.Controls.Converters
{
public class MarginMultiplierConverter : IValueConverter
{
public double Indent { get; set; }
public bool Left { get; set; } = false;
public bool Top { get; set; } = false;
public bool Right { get; set; } = false;
public bool Bottom { get; set; } = false;
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is int depth))
return new Thickness(0);
return new Thickness(Left ? Indent * depth : 0, Top ? Indent * depth : 0, Right ? Indent * depth : 0, Bottom ? Indent * depth : 0);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new System.NotImplementedException();
}
}
}

42
src/Avalonia.Controls/TreeView.cs

@ -1,6 +1,8 @@
// Copyright (c) The Avalonia Project. All rights reserved. // Copyright (c) The Avalonia Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information. // Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using Avalonia.Controls.Generators; using Avalonia.Controls.Generators;
using Avalonia.Controls.Primitives; using Avalonia.Controls.Primitives;
@ -31,6 +33,14 @@ namespace Avalonia.Controls
o => o.SelectedItem, o => o.SelectedItem,
(o, v) => o.SelectedItem = v); (o, v) => o.SelectedItem = v);
/// <summary>
/// Defines the <see cref="SelectedItemChanged"/> event.
/// </summary>
public static readonly RoutedEvent<SelectionChangedEventArgs> SelectedItemChangedEvent =
RoutedEvent.Register<TreeView, SelectionChangedEventArgs>(
"SelectedItemChanged",
RoutingStrategies.Bubble);
private object _selectedItem; private object _selectedItem;
/// <summary> /// <summary>
@ -41,6 +51,15 @@ namespace Avalonia.Controls
// HACK: Needed or SelectedItem property will not be found in Release build. // HACK: Needed or SelectedItem property will not be found in Release build.
} }
/// <summary>
/// Occurs when the control's selection changes.
/// </summary>
public event EventHandler<SelectionChangedEventArgs> SelectedItemChanged
{
add { AddHandler(SelectedItemChangedEvent, value); }
remove { RemoveHandler(SelectedItemChangedEvent, value); }
}
/// <summary> /// <summary>
/// Gets the <see cref="ITreeItemContainerGenerator"/> for the tree view. /// Gets the <see cref="ITreeItemContainerGenerator"/> for the tree view.
/// </summary> /// </summary>
@ -74,6 +93,7 @@ namespace Avalonia.Controls
MarkContainerSelected(container, false); MarkContainerSelected(container, false);
} }
var oldItem = _selectedItem;
SetAndRaise(SelectedItemProperty, ref _selectedItem, value); SetAndRaise(SelectedItemProperty, ref _selectedItem, value);
if (_selectedItem != null) if (_selectedItem != null)
@ -86,6 +106,28 @@ namespace Avalonia.Controls
container.BringIntoView(); container.BringIntoView();
} }
} }
if (oldItem != _selectedItem)
{
// Fire the SelectionChanged event
List<object> removed = new List<object>();
if (oldItem != null)
{
removed.Add(oldItem);
}
List<object> added = new List<object>();
if (_selectedItem != null)
{
added.Add(_selectedItem);
}
var changed = new SelectionChangedEventArgs(
SelectedItemChangedEvent,
added,
removed);
RaiseEvent(changed);
}
} }
} }

36
src/Avalonia.Controls/TreeViewItem.cs

@ -21,7 +21,7 @@ namespace Avalonia.Controls
/// </summary> /// </summary>
public static readonly DirectProperty<TreeViewItem, bool> IsExpandedProperty = public static readonly DirectProperty<TreeViewItem, bool> IsExpandedProperty =
AvaloniaProperty.RegisterDirect<TreeViewItem, bool>( AvaloniaProperty.RegisterDirect<TreeViewItem, bool>(
"IsExpanded", nameof(IsExpanded),
o => o.IsExpanded, o => o.IsExpanded,
(o, v) => o.IsExpanded = v); (o, v) => o.IsExpanded = v);
@ -31,17 +31,25 @@ namespace Avalonia.Controls
public static readonly StyledProperty<bool> IsSelectedProperty = public static readonly StyledProperty<bool> IsSelectedProperty =
ListBoxItem.IsSelectedProperty.AddOwner<TreeViewItem>(); ListBoxItem.IsSelectedProperty.AddOwner<TreeViewItem>();
/// <summary>
/// Defines the <see cref="Level"/> property.
/// </summary>
public static readonly DirectProperty<TreeViewItem, int> LevelProperty =
AvaloniaProperty.RegisterDirect<TreeViewItem, int>(
nameof(Level), o => o.Level);
private static readonly ITemplate<IPanel> DefaultPanel = private static readonly ITemplate<IPanel> DefaultPanel =
new FuncTemplate<IPanel>(() => new StackPanel()); new FuncTemplate<IPanel>(() => new StackPanel());
private TreeView _treeView; private TreeView _treeView;
private bool _isExpanded; private bool _isExpanded;
private int _level;
/// <summary> /// <summary>
/// Initializes static members of the <see cref="TreeViewItem"/> class. /// Initializes static members of the <see cref="TreeViewItem"/> class.
/// </summary> /// </summary>
static TreeViewItem() static TreeViewItem()
{ {
SelectableMixin.Attach<TreeViewItem>(IsSelectedProperty); SelectableMixin.Attach<TreeViewItem>(IsSelectedProperty);
FocusableProperty.OverrideDefaultValue<TreeViewItem>(true); FocusableProperty.OverrideDefaultValue<TreeViewItem>(true);
ItemsPanelProperty.OverrideDefaultValue<TreeViewItem>(DefaultPanel); ItemsPanelProperty.OverrideDefaultValue<TreeViewItem>(DefaultPanel);
@ -65,6 +73,15 @@ namespace Avalonia.Controls
set { SetValue(IsSelectedProperty, value); } set { SetValue(IsSelectedProperty, value); }
} }
/// <summary>
/// Gets the level/indentation of the item.
/// </summary>
public int Level
{
get { return _level; }
private set { SetAndRaise(LevelProperty, ref _level, value); }
}
/// <summary> /// <summary>
/// Gets the <see cref="ITreeItemContainerGenerator"/> for the tree view. /// Gets the <see cref="ITreeItemContainerGenerator"/> for the tree view.
/// </summary> /// </summary>
@ -89,6 +106,8 @@ namespace Avalonia.Controls
base.OnAttachedToLogicalTree(e); base.OnAttachedToLogicalTree(e);
_treeView = this.GetLogicalAncestors().OfType<TreeView>().FirstOrDefault(); _treeView = this.GetLogicalAncestors().OfType<TreeView>().FirstOrDefault();
Level = CalculateDistanceFromLogicalParent<TreeView>(this) - 1;
if (ItemTemplate == null && _treeView?.ItemTemplate != null) if (ItemTemplate == null && _treeView?.ItemTemplate != null)
{ {
ItemTemplate = _treeView.ItemTemplate; ItemTemplate = _treeView.ItemTemplate;
@ -126,5 +145,18 @@ namespace Avalonia.Controls
// Don't call base.OnKeyDown - let events bubble up to containing TreeView. // Don't call base.OnKeyDown - let events bubble up to containing TreeView.
} }
private static int CalculateDistanceFromLogicalParent<T>(ILogical logical, int @default = -1) where T : class
{
var result = 0;
while (logical != null && logical.GetType() != typeof(T))
{
++result;
logical = logical.LogicalParent;
}
return logical != null ? result : @default;
}
} }
} }

6
src/Avalonia.Styling/Styling/PropertyEqualsSelector.cs

@ -60,7 +60,7 @@ namespace Avalonia.Styling
builder.Append(_property.Name); builder.Append(_property.Name);
builder.Append('='); builder.Append('=');
builder.Append(_value); builder.Append(_value ?? string.Empty);
builder.Append(']'); builder.Append(']');
_selectorString = builder.ToString(); _selectorString = builder.ToString();
@ -78,11 +78,11 @@ namespace Avalonia.Styling
} }
else if (subscribe) else if (subscribe)
{ {
return new SelectorMatch(control.GetObservable(_property).Select(v => Equals(v, _value))); return new SelectorMatch(control.GetObservable(_property).Select(v => Equals(v ?? string.Empty, _value)));
} }
else else
{ {
return new SelectorMatch(control.GetValue(_property).Equals(_value)); return new SelectorMatch((control.GetValue(_property) ?? string.Empty).Equals(_value));
} }
} }

74
src/Avalonia.Themes.Default/Accents/BaseLight.xaml

@ -1,30 +1,56 @@
<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"
xmlns:sys="clr-namespace:System;assembly=mscorlib"> xmlns:sys="clr-namespace:System;assembly=mscorlib">
<Style.Resources> <Style.Resources>
<SolidColorBrush x:Key="ThemeBackgroundBrush">#FFFFFFFF</SolidColorBrush>
<SolidColorBrush x:Key="ThemeBorderLightBrush">#FFAAAAAA</SolidColorBrush>
<SolidColorBrush x:Key="ThemeBorderMidBrush">#FF888888</SolidColorBrush>
<SolidColorBrush x:Key="ThemeBorderDarkBrush">#FF333333</SolidColorBrush>
<SolidColorBrush x:Key="ThemeControlLightBrush">#FFFFFFFF</SolidColorBrush>
<SolidColorBrush x:Key="ThemeControlMidBrush">#FFAAAAAA</SolidColorBrush>
<SolidColorBrush x:Key="ThemeControlDarkBrush">#FF888888</SolidColorBrush>
<SolidColorBrush x:Key="ThemeForegroundBrush">#FF000000</SolidColorBrush>
<SolidColorBrush x:Key="ThemeForegroundLightBrush">#FF808080</SolidColorBrush>
<SolidColorBrush x:Key="HighlightBrush">#FF086F9E</SolidColorBrush> <Color x:Key="ThemeAccentColor">#CC119EDA</Color>
<SolidColorBrush x:Key="ThemeAccentBrush">#CC119EDA</SolidColorBrush> <Color x:Key="ThemeAccentColor2">#99119EDA</Color>
<SolidColorBrush x:Key="ThemeAccentBrush2">#99119EDA</SolidColorBrush> <Color x:Key="ThemeAccentColor3">#66119EDA</Color>
<SolidColorBrush x:Key="ThemeAccentBrush3">#66119EDA</SolidColorBrush> <Color x:Key="ThemeAccentColor4">#33119EDA</Color>
<SolidColorBrush x:Key="ThemeAccentBrush4">#33119EDA</SolidColorBrush>
<SolidColorBrush x:Key="ErrorBrush">Red</SolidColorBrush>
<SolidColorBrush x:Key="ErrorBrushLight">#10ff0000</SolidColorBrush>
<Thickness x:Key="ThemeBorderThickness">2</Thickness> <Color x:Key="ThemeBackgroundColor">#FFFFFFFF</Color>
<sys:Double x:Key="ThemeDisabledOpacity">0.5</sys:Double> <Color x:Key="ThemeBorderLightColor">#FFAAAAAA</Color>
<Color x:Key="ThemeBorderMidColor">#FF888888</Color>
<Color x:Key="ThemeBorderDarkColor">#FF333333</Color>
<Color x:Key="ThemeControlLightColor">#FFFFFFFF</Color>
<Color x:Key="ThemeControlMidColor">#FFAAAAAA</Color>
<Color x:Key="ThemeControlDarkColor">#FF888888</Color>
<Color x:Key="ThemeControlHighlightLowColor">#FFF0F0F0</Color>
<Color x:Key="ThemeControlHighlightMidColor">#FFD0D0D0</Color>
<Color x:Key="ThemeControlHighlightDarkColor">#FF808080</Color>
<Color x:Key="ThemeForegroundColor">#FF000000</Color>
<Color x:Key="ThemeForegroundLightColor">#FF808080</Color>
<sys:Double x:Key="FontSizeSmall">10</sys:Double> <Color x:Key="HighlightColor">#FF086F9E</Color>
<sys:Double x:Key="FontSizeNormal">12</sys:Double> <Color x:Key="ErrorColor">#FFFF0000</Color>
<sys:Double x:Key="FontSizeLarge">16</sys:Double> <Color x:Key="ErrorLightColor">#10FF0000</Color>
</Style.Resources>
</Style> <SolidColorBrush x:Key="ThemeBackgroundBrush" Color="{DynamicResource ThemeBackgroundColor}"></SolidColorBrush>
<SolidColorBrush x:Key="ThemeBorderLightBrush" Color="{DynamicResource ThemeBorderLightColor}"></SolidColorBrush>
<SolidColorBrush x:Key="ThemeBorderMidBrush" Color="{DynamicResource ThemeBorderMidColor}"></SolidColorBrush>
<SolidColorBrush x:Key="ThemeBorderDarkBrush" Color="{DynamicResource ThemeBorderDarkColor}"></SolidColorBrush>
<SolidColorBrush x:Key="ThemeControlLightBrush" Color="{DynamicResource ThemeControlLightColor}"></SolidColorBrush>
<SolidColorBrush x:Key="ThemeControlMidBrush" Color="{DynamicResource ThemeControlMidColor}"></SolidColorBrush>
<SolidColorBrush x:Key="ThemeControlDarkBrush" Color="{DynamicResource ThemeControlDarkColor}"></SolidColorBrush>
<SolidColorBrush x:Key="ThemeControlHighlightLowBrush" Color="{DynamicResource ThemeControlHighlightLowColor}"></SolidColorBrush>
<SolidColorBrush x:Key="ThemeControlHighlightMidBrush" Color="{DynamicResource ThemeControlHighlightMidColor}"></SolidColorBrush>
<SolidColorBrush x:Key="ThemeControlHighlightDarkBrush" Color="{DynamicResource ThemeControlHighlightDarkColor}"></SolidColorBrush>
<SolidColorBrush x:Key="ThemeForegroundBrush" Color="{DynamicResource ThemeForegroundColor}"></SolidColorBrush>
<SolidColorBrush x:Key="ThemeForegroundLightBrush" Color="{DynamicResource ThemeForegroundLightColor}"></SolidColorBrush>
<SolidColorBrush x:Key="HighlightBrush" Color="{DynamicResource HighlightColor}"></SolidColorBrush>
<SolidColorBrush x:Key="ThemeAccentBrush" Color="{DynamicResource ThemeAccentColor}"></SolidColorBrush>
<SolidColorBrush x:Key="ThemeAccentBrush2" Color="{DynamicResource ThemeAccentColor2}"></SolidColorBrush>
<SolidColorBrush x:Key="ThemeAccentBrush3" Color="{DynamicResource ThemeAccentColor3}"></SolidColorBrush>
<SolidColorBrush x:Key="ThemeAccentBrush4" Color="{DynamicResource ThemeAccentColor4}"></SolidColorBrush>
<SolidColorBrush x:Key="ErrorBrush" Color="{DynamicResource ErrorColor}"></SolidColorBrush>
<SolidColorBrush x:Key="ErrorLightBrush" Color="{DynamicResource ErrorLightColor}"></SolidColorBrush>
<Thickness x:Key="ThemeBorderThickness">2</Thickness>
<sys:Double x:Key="ThemeDisabledOpacity">0.5</sys:Double>
<sys:Double x:Key="FontSizeSmall">10</sys:Double>
<sys:Double x:Key="FontSizeNormal">12</sys:Double>
<sys:Double x:Key="FontSizeLarge">16</sys:Double>
</Style.Resources>
</Style>

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

@ -36,8 +36,4 @@
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> </Style>
</Styles>
<Style Selector="AutoCompleteBox ListBoxItem:pointerover">
<Setter Property="Background" Value="#ffd0d0d0"/>
</Style>
</Styles>

5
src/Avalonia.Themes.Default/CalendarButton.xaml

@ -7,6 +7,7 @@
<Styles xmlns="https://github.com/avaloniaui"> <Styles xmlns="https://github.com/avaloniaui">
<Style Selector="CalendarButton"> <Style Selector="CalendarButton">
<Setter Property="Foreground" Value="{DynamicResource ThemeBorderDarkBrush}" />
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush2}" /> <Setter Property="Background" Value="{DynamicResource ThemeAccentBrush2}" />
<Setter Property="FontSize" Value="{DynamicResource FontSizeSmall}" /> <Setter Property="FontSize" Value="{DynamicResource FontSizeSmall}" />
<Setter Property="HorizontalContentAlignment" Value="Center" /> <Setter Property="HorizontalContentAlignment" Value="Center" />
@ -28,7 +29,7 @@
<!--Focusable="False"--> <!--Focusable="False"-->
<ContentControl Name="Content" <ContentControl Name="Content"
Foreground="#FF333333" Foreground="{TemplateBinding Foreground}"
ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}" Content="{TemplateBinding Content}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
@ -77,4 +78,4 @@
<Style Selector="CalendarButton:btnfocused /template/ Rectangle#FocusVisual"> <Style Selector="CalendarButton:btnfocused /template/ Rectangle#FocusVisual">
<Setter Property="IsVisible" Value="True"/> <Setter Property="IsVisible" Value="True"/>
</Style> </Style>
</Styles> </Styles>

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

@ -42,7 +42,7 @@
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" VerticalAlignment="Stretch"
RenderTransformOrigin="0.5,0.5" RenderTransformOrigin="0.5,0.5"
Fill="#FF000000" Fill="{DynamicResource ThemeForegroundBrush}"
Stretch="Fill" Stretch="Fill"
Data="M8.1772461,11.029181 L10.433105,11.029181 L11.700684,12.801641 L12.973633,11.029181 L15.191895,11.029181 L12.844727,13.999395 L15.21875,17.060919 L12.962891,17.060919 L11.673828,15.256231 L10.352539,17.060919 L8.1396484,17.060919 L10.519043,14.042364 z" /> Data="M8.1772461,11.029181 L10.433105,11.029181 L11.700684,12.801641 L12.973633,11.029181 L15.191895,11.029181 L12.844727,13.999395 L15.21875,17.060919 L12.962891,17.060919 L11.673828,15.256231 L10.352539,17.060919 L8.1396484,17.060919 L10.519043,14.042364 z" />
@ -103,7 +103,7 @@
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundLightBrush}"/> <Setter Property="Foreground" Value="{DynamicResource ThemeForegroundLightBrush}"/>
</Style> </Style>
<Style Selector="CalendarDayButton:today /template/ ContentControl#Content"> <Style Selector="CalendarDayButton:today /template/ ContentControl#Content">
<Setter Property="Foreground" Value="#FFFFFFFF"/> <Setter Property="Foreground" Value="{DynamicResource ThemeControlLightBrush}"/>
</Style> </Style>
<Style Selector="CalendarDayButton /template/ Path#BlackoutVisual"> <Style Selector="CalendarDayButton /template/ Path#BlackoutVisual">
@ -113,4 +113,4 @@
<Setter Property="Opacity" Value="0.3"/> <Setter Property="Opacity" Value="0.3"/>
</Style> </Style>
</Styles> </Styles>

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

@ -153,7 +153,7 @@
<Rectangle Name="DisabledVisual" <Rectangle Name="DisabledVisual"
Stretch="Fill" Stretch="Fill"
Fill="#FFFFFFFF" Fill="{DynamicResource ThemeControlLightBrush}"
Opacity="{DynamicResource ThemeDisabledOpacity}" Opacity="{DynamicResource ThemeDisabledOpacity}"
Margin="0,2,0,2" /> Margin="0,2,0,2" />
@ -180,4 +180,4 @@
<Setter Property="IsVisible" Value="True"/> <Setter Property="IsVisible" Value="True"/>
</Style> </Style>
</Styles> </Styles>

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

@ -40,6 +40,9 @@
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> </Style>
<Style Selector="CheckBox:invalid /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="IsVisible" Value="False"/>
</Style>
<Style Selector="CheckBox:pointerover /template/ Border#border"> <Style Selector="CheckBox:pointerover /template/ Border#border">
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderDarkBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderDarkBrush}"/>
</Style> </Style>
@ -58,4 +61,4 @@
<Style Selector="CheckBox:disabled /template/ Border#border"> <Style Selector="CheckBox:disabled /template/ Border#border">
<Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}"/> <Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}"/>
</Style> </Style>
</Styles> </Styles>

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

@ -21,10 +21,10 @@
<Setter Property="ErrorTemplate"> <Setter Property="ErrorTemplate">
<DataTemplate> <DataTemplate>
<Canvas Width="14" Height="14" Margin="4 0 1 0" <Canvas Width="14" Height="14" Margin="4 0 1 0"
Background="#00FFFFFF"> Background="Transparent">
<Canvas.Styles> <Canvas.Styles>
<Style Selector="ToolTip"> <Style Selector="ToolTip">
<Setter Property="Background" Value="{DynamicResource ErrorBrushLight}"/> <Setter Property="Background" Value="{DynamicResource ErrorLightBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ErrorBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ErrorBrush}"/>
</Style> </Style>
</Canvas.Styles> </Canvas.Styles>
@ -35,4 +35,4 @@
</Canvas> </Canvas>
</DataTemplate> </DataTemplate>
</Setter> </Setter>
</Style> </Style>

35
src/Avalonia.Themes.Default/DatePicker.xaml

@ -6,7 +6,8 @@
--> -->
<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"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<Style Selector="DatePicker"> <Style Selector="DatePicker">
<Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}"/> <Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}"/>
@ -28,7 +29,7 @@
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
Margin="0" Margin="0"
Background="#FFFFFFFF" Background="{DynamicResource ThemeControlLightBrush}"
ColumnDefinitions="*,*,*,*" ColumnDefinitions="*,*,*,*"
RowDefinitions="23*,19*,19*,19*" RowDefinitions="23*,19*,19*,19*"
ClipToBounds="False"> ClipToBounds="False">
@ -54,19 +55,21 @@
Stroke="{DynamicResource ThemeBorderDarkBrush}" Stroke="{DynamicResource ThemeBorderDarkBrush}"
Fill="{DynamicResource ThemeAccentBrush}"> Fill="{DynamicResource ThemeAccentBrush}">
</Rectangle> </Rectangle>
<Path HorizontalAlignment="Center" <TextBlock Margin="0,-1,0,0"
Margin="4,3,4,3" VerticalAlignment="Center"
VerticalAlignment="Center" HorizontalAlignment="Center"
RenderTransformOrigin="0.5,0.5" Grid.Column="0"
Grid.Column="0" Grid.Row="1"
Grid.Row="1" Grid.ColumnSpan="4"
Grid.ColumnSpan="4" Grid.RowSpan="3"
Grid.RowSpan="3" FontSize="{DynamicResource FontSizeSmall}"
Fill="{DynamicResource ThemeBorderDarkBrush}" Foreground="{DynamicResource ThemeBorderDarkBrush}">
Stretch="Fill" <TextBlock.Text>
Data="M11.426758,8.4305077 L11.749023,8.4305077 L11.749023,16.331387 L10.674805,16.331387 L10.674805,10.299648 L9.0742188,11.298672 L9.0742188,10.294277 C9.4788408,10.090176 9.9094238,9.8090878 10.365967,9.4510155 C10.82251,9.0929432 11.176106,8.7527733 11.426758,8.4305077 z M14.65086,8.4305077 L18.566387,8.4305077 L18.566387,9.3435936 L15.671368,9.3435936 L15.671368,11.255703 C15.936341,11.058764 16.27293,10.960293 16.681133,10.960293 C17.411602,10.960293 17.969301,11.178717 18.354229,11.615566 C18.739157,12.052416 18.931622,12.673672 18.931622,13.479336 C18.931622,15.452317 18.052553,16.438808 16.294415,16.438808 C15.560365,16.438808 14.951641,16.234707 14.468243,15.826504 L14.881817,14.929531 C15.368796,15.326992 15.837872,15.525723 16.289043,15.525723 C17.298809,15.525723 17.803692,14.895514 17.803692,13.635098 C17.803692,12.460618 17.305971,11.873379 16.310528,11.873379 C15.83071,11.873379 15.399232,12.079271 15.016094,12.491055 L14.65086,12.238613 z" /> <Binding Source="{x:Static sys:DateTime.Today}" Path="Day"/>
</TextBlock.Text>
</TextBlock>
<Ellipse HorizontalAlignment="Center" VerticalAlignment="Center" Fill="#FFFFFFFF" StrokeThickness="0" Grid.ColumnSpan="4" Width="3" Height="3"/> <Ellipse HorizontalAlignment="Center" VerticalAlignment="Center" Fill="{DynamicResource ThemeControlLightBrush}" StrokeThickness="0" Grid.ColumnSpan="4" Width="3" Height="3"/>
</Grid> </Grid>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
@ -100,7 +103,7 @@
Width="20" Width="20"
Classes="CalendarDropDown" Classes="CalendarDropDown"
Foreground="{TemplateBinding Foreground}" Foreground="{TemplateBinding Foreground}"
Background="#00FFFFFF" Background="Transparent"
BorderThickness="0" BorderThickness="0"
Margin="2,0,2,0" Margin="2,0,2,0"
Padding="0" Padding="0"
@ -123,4 +126,4 @@
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderDarkBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderDarkBrush}"/>
</Style> </Style>
</Styles> </Styles>

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

@ -18,10 +18,24 @@
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> </Style>
<Style Selector="DropDownItem:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ThemeControlHighlightMidBrush}"/>
</Style>
<Style Selector="DropDownItem:selected /template/ ContentPresenter"> <Style Selector="DropDownItem:selected /template/ ContentPresenter">
<Setter Property="Background" Value="#fff0f0f0"/> <Setter Property="Background" Value="{DynamicResource ThemeAccentBrush4}"/>
</Style> </Style>
<Style Selector="DropDownItem:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="#ffd0d0d0"/> <Style Selector="DropDownItem:selected:focus /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush3}"/>
</Style>
<Style Selector="DropDownItem:selected:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush3}"/>
</Style>
<Style Selector="DropDownItem:selected:focus:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush2}"/>
</Style> </Style>
</Styles> </Styles>

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

@ -108,7 +108,7 @@
</Setter> </Setter>
</Style> </Style>
<Style Selector="Expander /template/ ToggleButton#PART_toggle:pointerover /template/ Border"> <Style Selector="Expander /template/ ToggleButton#PART_toggle:pointerover /template/ Border">
<Setter Property="BorderBrush" Value="#ffaaaaaa" /> <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderLightBrush}" />
</Style> </Style>
<Style Selector="Expander:down:expanded /template/ ToggleButton#PART_toggle /template/ Path"> <Style Selector="Expander:down:expanded /template/ ToggleButton#PART_toggle /template/ Path">
<Setter Property="RenderTransform"> <Setter Property="RenderTransform">
@ -135,4 +135,4 @@
<RotateTransform Angle="0" /> <RotateTransform Angle="0" />
</Setter> </Setter>
</Style> </Style>
</Styles> </Styles>

23
src/Avalonia.Themes.Default/ListBoxItem.xaml

@ -1,6 +1,9 @@
<Styles xmlns="https://github.com/avaloniaui"> <Styles xmlns="https://github.com/avaloniaui">
<Style Selector="ListBoxItem"> <Style Selector="ListBoxItem">
<Setter Property="Background" Value="Transparent"/> <Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Padding" Value="2 1"/>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<ContentPresenter Name="PART_ContentPresenter" <ContentPresenter Name="PART_ContentPresenter"
@ -15,10 +18,24 @@
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> </Style>
<Style Selector="ListBoxItem:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ThemeControlHighlightMidBrush}"/>
</Style>
<Style Selector="ListBoxItem:selected /template/ ContentPresenter"> <Style Selector="ListBoxItem:selected /template/ ContentPresenter">
<Setter Property="Background" Value="#fff0f0f0"/> <Setter Property="Background" Value="{DynamicResource ThemeAccentBrush4}"/>
</Style> </Style>
<Style Selector="ListBoxItem:selected:focus /template/ ContentPresenter"> <Style Selector="ListBoxItem:selected:focus /template/ ContentPresenter">
<Setter Property="Background" Value="#ffd0d0d0"/> <Setter Property="Background" Value="{DynamicResource ThemeAccentBrush3}"/>
</Style>
<Style Selector="ListBoxItem:selected:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush3}"/>
</Style>
<Style Selector="ListBoxItem:selected:focus:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush2}"/>
</Style> </Style>
</Styles> </Styles>

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

@ -10,7 +10,7 @@
Grid.Column="0"> Grid.Column="0">
<Path Data="M 0,4 C0,4 0,6 0,6 0,6 3.5,2.5 3.5,2.5 3.5,2.5 7,6 7,6 7,6 7,4 7,4 7,4 3.5,0.5 3.5,0.5 3.5,0.5 0,4 0,4 z" <Path Data="M 0,4 C0,4 0,6 0,6 0,6 3.5,2.5 3.5,2.5 3.5,2.5 7,6 7,6 7,6 7,4 7,4 7,4 3.5,0.5 3.5,0.5 3.5,0.5 0,4 0,4 z"
Stretch="Uniform" Stretch="Uniform"
Fill="Gray" /> Fill="{DynamicResource ThemeForegroundLightBrush}" />
</RepeatButton> </RepeatButton>
<Track Grid.Row="1" <Track Grid.Row="1"
Grid.Column="1" Grid.Column="1"
@ -41,7 +41,7 @@
Grid.Column="2"> Grid.Column="2">
<Path Data="M 0,2.5 C0,2.5 0,0.5 0,0.5 0,0.5 3.5,4 3.5,4 3.5,4 7,0.5 7,0.5 7,0.5 7,2.5 7,2.5 7,2.5 3.5,6 3.5,6 3.5,6 0,2.5 0,2.5 z" <Path Data="M 0,2.5 C0,2.5 0,0.5 0,0.5 0,0.5 3.5,4 3.5,4 3.5,4 7,0.5 7,0.5 7,0.5 7,2.5 7,2.5 7,2.5 3.5,6 3.5,6 3.5,6 0,2.5 0,2.5 z"
Stretch="Uniform" Stretch="Uniform"
Fill="Gray" /> Fill="{DynamicResource ThemeForegroundLightBrush}" />
</RepeatButton> </RepeatButton>
</Grid> </Grid>
</Border> </Border>
@ -61,7 +61,7 @@
Grid.Column="0"> Grid.Column="0">
<Path Data="M 3.18,7 C3.18,7 5,7 5,7 5,7 1.81,3.5 1.81,3.5 1.81,3.5 5,0 5,0 5,0 3.18,0 3.18,0 3.18,0 0,3.5 0,3.5 0,3.5 3.18,7 3.18,7 z" <Path Data="M 3.18,7 C3.18,7 5,7 5,7 5,7 1.81,3.5 1.81,3.5 1.81,3.5 5,0 5,0 5,0 3.18,0 3.18,0 3.18,0 0,3.5 0,3.5 0,3.5 3.18,7 3.18,7 z"
Stretch="Uniform" Stretch="Uniform"
Fill="Gray" /> Fill="{DynamicResource ThemeForegroundLightBrush}" />
</RepeatButton> </RepeatButton>
<Track Grid.Row="1" <Track Grid.Row="1"
Grid.Column="1" Grid.Column="1"
@ -92,7 +92,7 @@
Grid.Column="2"> Grid.Column="2">
<Path Data="M 1.81,7 C1.81,7 0,7 0,7 0,7 3.18,3.5 3.18,3.5 3.18,3.5 0,0 0,0 0,0 1.81,0 1.81,0 1.81,0 5,3.5 5,3.5 5,3.5 1.81,7 1.81,7 z" <Path Data="M 1.81,7 C1.81,7 0,7 0,7 0,7 3.18,3.5 3.18,3.5 3.18,3.5 0,0 0,0 0,0 1.81,0 1.81,0 1.81,0 5,3.5 5,3.5 5,3.5 1.81,7 1.81,7 z"
Stretch="Uniform" Stretch="Uniform"
Fill="Gray" /> Fill="{DynamicResource ThemeForegroundLightBrush}" />
</RepeatButton> </RepeatButton>
</Grid> </Grid>
</Border> </Border>
@ -124,4 +124,4 @@
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> </Style>
</Styles> </Styles>

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

@ -80,10 +80,11 @@
</Style> </Style>
<Style Selector="Slider /template/ RepeatButton.repeattrack"> <Style Selector="Slider /template/ RepeatButton.repeattrack">
<Setter Property="Background" Value="Transparent"/> <Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{DynamicResource ThemeBorderLightBrush}"/>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Border Background="{TemplateBinding Background}" /> <Border Background="{TemplateBinding Background}" />
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> </Style>
</Styles> </Styles>

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

@ -1,69 +1,92 @@
<Styles xmlns="https://github.com/avaloniaui"> <Styles xmlns="https://github.com/avaloniaui"
<Style Selector="TreeViewItem"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
<Setter Property="Padding" Value="2"/> xmlns:converters="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls">
<Setter Property="Template"> <Style Selector="TreeViewItem">
<ControlTemplate> <Style.Resources>
<StackPanel> <converters:MarginMultiplierConverter Indent="16" Left="True" x:Key="LeftMarginConverter" />
<Grid ColumnDefinitions="16, Auto"> </Style.Resources>
<ToggleButton Name="expander" <Setter Property="Padding" Value="2"/>
Focusable="False" <Setter Property="Background" Value="Transparent"/>
IsChecked="{TemplateBinding IsExpanded, Mode=TwoWay}"/> <Setter Property="Template">
<ContentPresenter Name="PART_HeaderPresenter" <ControlTemplate>
Background="{TemplateBinding Background}" <StackPanel>
BorderBrush="{TemplateBinding BorderBrush}" <Border Name="SelectionBorder"
BorderThickness="{TemplateBinding BorderThickness}" Focusable="True"
Content="{TemplateBinding Header}" Background="{TemplateBinding Background}"
Padding="{TemplateBinding Padding}" BorderBrush="{TemplateBinding BorderBrush}"
TemplatedControl.IsTemplateFocusTarget="True" BorderThickness="{TemplateBinding BorderThickness}"
Grid.Column="1"/> TemplatedControl.IsTemplateFocusTarget="True">
</Grid> <Grid ColumnDefinitions="16, *"
<ItemsPresenter Name="PART_ItemsPresenter" Margin="{TemplateBinding Level, Mode=OneWay, Converter={StaticResource LeftMarginConverter}}" >
IsVisible="{TemplateBinding IsExpanded}" <ToggleButton Name="expander"
Items="{TemplateBinding Items}" Focusable="False"
ItemsPanel="{TemplateBinding ItemsPanel}" IsChecked="{TemplateBinding IsExpanded, Mode=TwoWay}"/>
Margin="24,0,0,0" <ContentPresenter Name="PART_HeaderPresenter"
MemberSelector="{TemplateBinding MemberSelector}"/> Focusable="False"
</StackPanel> Content="{TemplateBinding Header}"
</ControlTemplate> HorizontalContentAlignment="{TemplateBinding HorizontalAlignment}"
</Setter> Padding="{TemplateBinding Padding}"
</Style> Grid.Column="1"/>
</Grid>
</Border>
<ItemsPresenter Name="PART_ItemsPresenter"
IsVisible="{TemplateBinding IsExpanded}"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}"
MemberSelector="{TemplateBinding MemberSelector}"/>
</StackPanel>
</ControlTemplate>
</Setter>
</Style>
<Style Selector="TreeViewItem /template/ ToggleButton#expander"> <Style Selector="TreeViewItem /template/ ToggleButton#expander">
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Border Background="Transparent" <Border Background="Transparent"
Width="14" Width="14"
Height="12" Height="12"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center"> VerticalAlignment="Center">
<Path Fill="{DynamicResource 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"/>
</Border> </Border>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> </Style>
<Style Selector="TreeViewItem /template/ ContentPresenter#PART_HeaderPresenter"> <Style Selector="TreeViewItem /template/ ContentPresenter#PART_HeaderPresenter">
<Setter Property="Padding" Value="2"/> <Setter Property="Padding" Value="2"/>
</Style> </Style>
<Style Selector="TreeViewItem:selected /template/ ContentPresenter#PART_HeaderPresenter">
<Setter Property="Background" Value="#fff0f0f0"/>
</Style>
<Style Selector="TreeViewItem:selected:focus /template/ ContentPresenter#PART_HeaderPresenter">
<Setter Property="Background" Value="#ffd0d0d0"/>
</Style>
<Style Selector="TreeViewItem /template/ ToggleButton#expander:checked">
<Setter Property="RenderTransform">
<RotateTransform Angle="45"/>
</Setter>
</Style>
<Style Selector="TreeViewItem:empty /template/ ToggleButton#expander"> <Style Selector="TreeViewItem /template/ Border#SelectionBorder:pointerover">
<Setter Property="IsVisible" Value="False"/> <Setter Property="Background" Value="{DynamicResource ThemeControlHighlightMidBrush}"/>
</Style> </Style>
</Styles>
<Style Selector="TreeViewItem:selected /template/ Border#SelectionBorder">
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush4}"/>
</Style>
<Style Selector="TreeViewItem:selected /template/ Border#SelectionBorder:focus">
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush3}"/>
</Style>
<Style Selector="TreeViewItem:selected /template/ Border#SelectionBorder:pointerover">
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush3}"/>
</Style>
<Style Selector="TreeViewItem:selected /template/ Border#SelectionBorder:pointerover:focus">
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush2}"/>
</Style>
<Style Selector="TreeViewItem /template/ ToggleButton#expander:checked">
<Setter Property="RenderTransform">
<RotateTransform Angle="45"/>
</Setter>
</Style>
<Style Selector="TreeViewItem:empty /template/ ToggleButton#expander">
<Setter Property="IsVisible" Value="False"/>
</Style>
</Styles>

2
src/Avalonia.Visuals/Media/Typeface.cs

@ -7,6 +7,8 @@ namespace Avalonia.Media
/// </summary> /// </summary>
public class Typeface public class Typeface
{ {
public static Typeface Default = new Typeface(FontFamily.Default);
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Typeface"/> class. /// Initializes a new instance of the <see cref="Typeface"/> class.
/// </summary> /// </summary>

33
tests/Avalonia.Controls.UnitTests/TreeViewTests.cs

@ -166,6 +166,39 @@ namespace Avalonia.Controls.UnitTests
Assert.True(container.IsSelected); Assert.True(container.IsSelected);
} }
[Fact]
public void Setting_SelectedItem_Should_Raise_SelectedItemChanged_Event()
{
var tree = CreateTestTreeData();
var target = new TreeView
{
Template = CreateTreeViewTemplate(),
Items = tree,
};
var visualRoot = new TestRoot();
visualRoot.Child = target;
CreateNodeDataTemplate(target);
ApplyTemplates(target);
var item = tree[0].Children[1].Children[0];
var called = false;
target.SelectedItemChanged += (s, e) =>
{
Assert.Empty(e.RemovedItems);
Assert.Equal(1, e.AddedItems.Count);
Assert.Same(item, e.AddedItems[0]);
called = true;
};
target.SelectedItem = item;
Assert.True(called);
}
[Fact] [Fact]
public void LogicalChildren_Should_Be_Set() public void LogicalChildren_Should_Be_Set()
{ {

Loading…
Cancel
Save