Merge pull request #103 from irihitech/empty

fix: make content invisible when content is null.
This commit is contained in:
Dong Bin 2023-02-24 00:19:29 +08:00 committed by GitHub
commit 5b352b6f81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,6 +30,8 @@
VerticalAlignment="Top"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
IsVisible="{TemplateBinding Content,
Converter={x:Static ObjectConverters.IsNotNull}}"
RecognizesAccessKey="True" />
<Grid
Grid.Row="1"
@ -123,22 +125,17 @@
<Setter Property="ContentPresenter.IsVisible" Value="True" />
</Style>
<Style Selector="^ /template/ Border#SwitchBackgroundBorder">
<Setter Property="Border.Background"
Value="{DynamicResource ToggleSwitchContainerUnCheckedDefaultBackground}" />
<Setter Property="Border.Background" Value="{DynamicResource ToggleSwitchContainerUnCheckedDefaultBackground}" />
</Style>
<Style Selector="^:pointerover /template/ Border#SwitchBackgroundBorder">
<Setter Property="Border.Background"
Value="{DynamicResource ToggleSwitchContainerUnCheckedPointerOverBackground}" />
<Setter Property="Border.Background" Value="{DynamicResource ToggleSwitchContainerUnCheckedPointerOverBackground}" />
</Style>
<Style Selector="^:pressed /template/ Border#SwitchBackgroundBorder">
<Setter Property="Border.Background"
Value="{DynamicResource ToggleSwitchContainerUnCheckedPressedBackground}" />
<Setter Property="Border.Background" Value="{DynamicResource ToggleSwitchContainerUnCheckedPressedBackground}" />
</Style>
<Style Selector="^:disabled /template/ Border#SwitchBackgroundBorder">
<Setter Property="Border.Background"
Value="{DynamicResource ToggleSwitchContainerUnCheckedDisabledBackground}" />
<Setter Property="Border.BorderBrush"
Value="{DynamicResource ToggleSwitchContainerUnCheckedDisabledBorderBrush}" />
<Setter Property="Border.Background" Value="{DynamicResource ToggleSwitchContainerUnCheckedDisabledBackground}" />
<Setter Property="Border.BorderBrush" Value="{DynamicResource ToggleSwitchContainerUnCheckedDisabledBorderBrush}" />
<Setter Property="Border.BorderThickness" Value="1" />
</Style>
</Style>
@ -151,36 +148,33 @@
<Setter Property="ContentPresenter.IsVisible" Value="False" />
</Style>
<Style Selector="^ /template/ Border#SwitchBackgroundBorder">
<Setter Property="Border.Background"
Value="{DynamicResource ToggleSwitchContainerCheckedDefaultBackground}" />
<Setter Property="Border.Background" Value="{DynamicResource ToggleSwitchContainerCheckedDefaultBackground}" />
</Style>
<Style Selector="^:pointerover /template/ Border#SwitchBackgroundBorder">
<Setter Property="Border.Background"
Value="{DynamicResource ToggleSwitchContainerCheckedPointerOverBackground}" />
<Setter Property="Border.Background" Value="{DynamicResource ToggleSwitchContainerCheckedPointerOverBackground}" />
</Style>
<Style Selector="^:pressed /template/ Border#SwitchBackgroundBorder">
<Setter Property="Border.Background"
Value="{DynamicResource ToggleSwitchContainerCheckedPressedBackground}" />
<Setter Property="Border.Background" Value="{DynamicResource ToggleSwitchContainerCheckedPressedBackground}" />
</Style>
<Style Selector="^:disabled /template/ Border#SwitchBackgroundBorder">
<Setter Property="Border.Background"
Value="{DynamicResource ToggleSwitchContainerCheckedDisabledBackground}" />
<Setter Property="Border.Background" Value="{DynamicResource ToggleSwitchContainerCheckedDisabledBackground}" />
</Style>
</Style>
</ControlTheme>
<ControlTheme x:Key="ButtonToggleSwitch" BasedOn="{StaticResource {x:Type ToggleSwitch}}" TargetType="ToggleSwitch">
<ControlTheme
x:Key="ButtonToggleSwitch"
BasedOn="{StaticResource {x:Type ToggleSwitch}}"
TargetType="ToggleSwitch">
<Setter Property="Template">
<ControlTemplate TargetType="ToggleSwitch">
<Border
Name="Background"
Cursor="Hand"
Padding="8"
Background="{TemplateBinding Background}"
CornerRadius="3">
<Grid
Background="Transparent"
ColumnDefinitions="Auto">
CornerRadius="3"
Cursor="Hand">
<Grid Background="Transparent" ColumnDefinitions="Auto">
<Grid x:Name="PART_SwitchKnob" />
<Grid x:Name="PART_MovingKnobs" />
<ContentPresenter
@ -205,7 +199,10 @@
</Style>
</ControlTheme>
<ControlTheme x:Key="SimpleToggleSwitch" BasedOn="{StaticResource {x:Type ToggleSwitch}}" TargetType="ToggleSwitch">
<ControlTheme
x:Key="SimpleToggleSwitch"
BasedOn="{StaticResource {x:Type ToggleSwitch}}"
TargetType="ToggleSwitch">
<Setter Property="Template">
<ControlTemplate TargetType="ToggleSwitch">
<Grid