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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
35 additions and
7 deletions
-
src/Avalonia.Controls/Presenters/ContentPresenter.cs
-
src/Avalonia.Themes.Default/ToggleSwitch.xaml
-
src/Avalonia.Themes.Fluent/DataValidationErrors.xaml
-
src/Avalonia.Themes.Fluent/ToggleSwitch.xaml
|
|
|
@ -1,9 +1,9 @@ |
|
|
|
using System; |
|
|
|
|
|
|
|
using Avalonia.Controls.Metadata; |
|
|
|
using Avalonia.Controls.Primitives; |
|
|
|
using Avalonia.Controls.Templates; |
|
|
|
using Avalonia.Controls.Utils; |
|
|
|
using Avalonia.Data; |
|
|
|
using Avalonia.Input; |
|
|
|
using Avalonia.Layout; |
|
|
|
using Avalonia.LogicalTree; |
|
|
|
using Avalonia.Media; |
|
|
|
@ -14,6 +14,7 @@ namespace Avalonia.Controls.Presenters |
|
|
|
/// <summary>
|
|
|
|
/// Presents a single item of data inside a <see cref="TemplatedControl"/> template.
|
|
|
|
/// </summary>
|
|
|
|
[PseudoClasses(":empty")] |
|
|
|
public class ContentPresenter : Control, IContentPresenter |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
@ -102,6 +103,11 @@ namespace Avalonia.Controls.Presenters |
|
|
|
TemplatedParentProperty.Changed.AddClassHandler<ContentPresenter>((x, e) => x.TemplatedParentChanged(e)); |
|
|
|
} |
|
|
|
|
|
|
|
public ContentPresenter() |
|
|
|
{ |
|
|
|
UpdatePseudoClasses(); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets a brush with which to paint the background.
|
|
|
|
/// </summary>
|
|
|
|
@ -424,9 +430,15 @@ namespace Avalonia.Controls.Presenters |
|
|
|
_recyclingDataTemplate = null; |
|
|
|
} |
|
|
|
|
|
|
|
UpdatePseudoClasses(); |
|
|
|
InvalidateMeasure(); |
|
|
|
} |
|
|
|
|
|
|
|
private void UpdatePseudoClasses() |
|
|
|
{ |
|
|
|
PseudoClasses.Set(":empty", Content is null); |
|
|
|
} |
|
|
|
|
|
|
|
private double GetLayoutScale() |
|
|
|
{ |
|
|
|
var result = (VisualRoot as ILayoutRoot)?.LayoutScaling ?? 1.0; |
|
|
|
|
|
|
|
@ -87,7 +87,6 @@ |
|
|
|
Grid.Row="0" |
|
|
|
Content="{TemplateBinding Content}" |
|
|
|
ContentTemplate="{TemplateBinding ContentTemplate}" |
|
|
|
Margin="{DynamicResource ToggleSwitchTopHeaderMargin}" |
|
|
|
VerticalAlignment="Top"/> |
|
|
|
|
|
|
|
<Grid Grid.Row="1" |
|
|
|
@ -163,6 +162,13 @@ |
|
|
|
</Setter> |
|
|
|
</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 --> |
|
|
|
<Style Selector="ToggleSwitch /template/ Grid#SwitchAreaGrid"> |
|
|
|
<Setter Property="Background" Value="{DynamicResource ToggleSwitchContainerBackground}"/> |
|
|
|
|
|
|
|
@ -31,12 +31,16 @@ |
|
|
|
</Setter> |
|
|
|
<Setter Property="ErrorTemplate"> |
|
|
|
<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"> |
|
|
|
<Canvas.Styles> |
|
|
|
<Style Selector="ToolTip"> |
|
|
|
<Style Selector="Canvas#PART_ErrorTemplateCanvas ToolTip"> |
|
|
|
<Setter Property="BorderBrush" Value="{DynamicResource SystemControlErrorTextForegroundBrush}"/> |
|
|
|
</Style> |
|
|
|
<Style Selector="Canvas#PART_ErrorTemplateCanvas ToolTip TextBlock"> |
|
|
|
<Setter Property="TextWrapping" Value="Wrap" /> |
|
|
|
</Style> |
|
|
|
</Canvas.Styles> |
|
|
|
<ToolTip.Tip> |
|
|
|
<ItemsControl Items="{Binding}"/> |
|
|
|
|
|
|
|
@ -31,7 +31,7 @@ |
|
|
|
Text="The previewer Shows a preview off your code, this could slow down your system" |
|
|
|
TextWrapping="Wrap"/> |
|
|
|
<ToggleSwitch |
|
|
|
Content="Previewer" |
|
|
|
Background="Green" |
|
|
|
IsChecked="True" /> |
|
|
|
</StackPanel> |
|
|
|
</StackPanel> |
|
|
|
@ -53,7 +53,6 @@ |
|
|
|
Grid.Row="0" |
|
|
|
Content="{TemplateBinding Content}" |
|
|
|
ContentTemplate="{TemplateBinding ContentTemplate}" |
|
|
|
Margin="{DynamicResource ToggleSwitchTopHeaderMargin}" |
|
|
|
VerticalAlignment="Top"/> |
|
|
|
|
|
|
|
<Grid Grid.Row="1" |
|
|
|
@ -129,6 +128,13 @@ |
|
|
|
</Setter> |
|
|
|
</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 --> |
|
|
|
<Style Selector="ToggleSwitch /template/ Grid#SwitchAreaGrid"> |
|
|
|
<Setter Property="Background" Value="{DynamicResource ToggleSwitchContainerBackground}"/> |
|
|
|
|