Browse Source

Merge branch 'master' into fixes/4781-treeview-setting-bound-selected-item-null

pull/4785/head
Steven Kirk 6 years ago
committed by GitHub
parent
commit
55b3be3c8e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      src/Avalonia.Controls/Presenters/ContentPresenter.cs
  2. 8
      src/Avalonia.Themes.Default/ToggleSwitch.xaml
  3. 8
      src/Avalonia.Themes.Fluent/DataValidationErrors.xaml
  4. 10
      src/Avalonia.Themes.Fluent/ToggleSwitch.xaml

16
src/Avalonia.Controls/Presenters/ContentPresenter.cs

@ -1,9 +1,9 @@
using System; using System;
using Avalonia.Controls.Metadata;
using Avalonia.Controls.Primitives; using Avalonia.Controls.Primitives;
using Avalonia.Controls.Templates; using Avalonia.Controls.Templates;
using Avalonia.Controls.Utils; using Avalonia.Controls.Utils;
using Avalonia.Data;
using Avalonia.Input;
using Avalonia.Layout; using Avalonia.Layout;
using Avalonia.LogicalTree; using Avalonia.LogicalTree;
using Avalonia.Media; using Avalonia.Media;
@ -14,6 +14,7 @@ namespace Avalonia.Controls.Presenters
/// <summary> /// <summary>
/// Presents a single item of data inside a <see cref="TemplatedControl"/> template. /// Presents a single item of data inside a <see cref="TemplatedControl"/> template.
/// </summary> /// </summary>
[PseudoClasses(":empty")]
public class ContentPresenter : Control, IContentPresenter public class ContentPresenter : Control, IContentPresenter
{ {
/// <summary> /// <summary>
@ -102,6 +103,11 @@ namespace Avalonia.Controls.Presenters
TemplatedParentProperty.Changed.AddClassHandler<ContentPresenter>((x, e) => x.TemplatedParentChanged(e)); TemplatedParentProperty.Changed.AddClassHandler<ContentPresenter>((x, e) => x.TemplatedParentChanged(e));
} }
public ContentPresenter()
{
UpdatePseudoClasses();
}
/// <summary> /// <summary>
/// Gets or sets a brush with which to paint the background. /// Gets or sets a brush with which to paint the background.
/// </summary> /// </summary>
@ -424,9 +430,15 @@ namespace Avalonia.Controls.Presenters
_recyclingDataTemplate = null; _recyclingDataTemplate = null;
} }
UpdatePseudoClasses();
InvalidateMeasure(); InvalidateMeasure();
} }
private void UpdatePseudoClasses()
{
PseudoClasses.Set(":empty", Content is null);
}
private double GetLayoutScale() private double GetLayoutScale()
{ {
var result = (VisualRoot as ILayoutRoot)?.LayoutScaling ?? 1.0; var result = (VisualRoot as ILayoutRoot)?.LayoutScaling ?? 1.0;

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

@ -87,7 +87,6 @@
Grid.Row="0" Grid.Row="0"
Content="{TemplateBinding Content}" Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplate="{TemplateBinding ContentTemplate}"
Margin="{DynamicResource ToggleSwitchTopHeaderMargin}"
VerticalAlignment="Top"/> VerticalAlignment="Top"/>
<Grid Grid.Row="1" <Grid Grid.Row="1"
@ -163,6 +162,13 @@
</Setter> </Setter>
</Style> </Style>
<Style Selector="ToggleSwitch /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Margin" Value="{DynamicResource ToggleSwitchTopHeaderMargin}" />
</Style>
<Style Selector="ToggleSwitch /template/ ContentPresenter#PART_ContentPresenter:empty">
<Setter Property="Margin" Value="0" />
</Style>
<!-- NormalState --> <!-- NormalState -->
<Style Selector="ToggleSwitch /template/ Grid#SwitchAreaGrid"> <Style Selector="ToggleSwitch /template/ Grid#SwitchAreaGrid">
<Setter Property="Background" Value="{DynamicResource ToggleSwitchContainerBackground}"/> <Setter Property="Background" Value="{DynamicResource ToggleSwitchContainerBackground}"/>

8
src/Avalonia.Themes.Fluent/DataValidationErrors.xaml

@ -31,12 +31,16 @@
</Setter> </Setter>
<Setter Property="ErrorTemplate"> <Setter Property="ErrorTemplate">
<DataTemplate> <DataTemplate>
<Canvas Width="14" Height="14" Margin="4 0 1 0" <Canvas Name="PART_ErrorTemplateCanvas"
Width="14" Height="14" Margin="4 0 1 0"
Background="Transparent"> Background="Transparent">
<Canvas.Styles> <Canvas.Styles>
<Style Selector="ToolTip"> <Style Selector="Canvas#PART_ErrorTemplateCanvas ToolTip">
<Setter Property="BorderBrush" Value="{DynamicResource SystemControlErrorTextForegroundBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource SystemControlErrorTextForegroundBrush}"/>
</Style> </Style>
<Style Selector="Canvas#PART_ErrorTemplateCanvas ToolTip TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
</Style>
</Canvas.Styles> </Canvas.Styles>
<ToolTip.Tip> <ToolTip.Tip>
<ItemsControl Items="{Binding}"/> <ItemsControl Items="{Binding}"/>

10
src/Avalonia.Themes.Fluent/ToggleSwitch.xaml

@ -31,7 +31,7 @@
Text="The previewer Shows a preview off your code, this could slow down your system" Text="The previewer Shows a preview off your code, this could slow down your system"
TextWrapping="Wrap"/> TextWrapping="Wrap"/>
<ToggleSwitch <ToggleSwitch
Content="Previewer" Background="Green"
IsChecked="True" /> IsChecked="True" />
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
@ -53,7 +53,6 @@
Grid.Row="0" Grid.Row="0"
Content="{TemplateBinding Content}" Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplate="{TemplateBinding ContentTemplate}"
Margin="{DynamicResource ToggleSwitchTopHeaderMargin}"
VerticalAlignment="Top"/> VerticalAlignment="Top"/>
<Grid Grid.Row="1" <Grid Grid.Row="1"
@ -129,6 +128,13 @@
</Setter> </Setter>
</Style> </Style>
<Style Selector="ToggleSwitch /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Margin" Value="{DynamicResource ToggleSwitchTopHeaderMargin}" />
</Style>
<Style Selector="ToggleSwitch /template/ ContentPresenter#PART_ContentPresenter:empty">
<Setter Property="Margin" Value="0" />
</Style>
<!-- NormalState --> <!-- NormalState -->
<Style Selector="ToggleSwitch /template/ Grid#SwitchAreaGrid"> <Style Selector="ToggleSwitch /template/ Grid#SwitchAreaGrid">
<Setter Property="Background" Value="{DynamicResource ToggleSwitchContainerBackground}"/> <Setter Property="Background" Value="{DynamicResource ToggleSwitchContainerBackground}"/>

Loading…
Cancel
Save