csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
304 lines
15 KiB
304 lines
15 KiB
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
x:ClassModifier="internal">
|
|
<Design.PreviewWith>
|
|
<Border Padding="20">
|
|
<StackPanel Spacing="20">
|
|
<CheckBox>Unchecked</CheckBox>
|
|
<CheckBox IsChecked="True">Checked</CheckBox>
|
|
<CheckBox IsThreeState="True" IsChecked="{x:Null}">Indeterminate</CheckBox>
|
|
<CheckBox Width="120">Checkbox should wrap its text</CheckBox>
|
|
</StackPanel>
|
|
</Border>
|
|
</Design.PreviewWith>
|
|
|
|
<StreamGeometry x:Key="CheckMarkPathData">M5.5 10.586 1.707 6.793A1 1 0 0 0 .293 8.207l4.5 4.5a1 1 0 0 0 1.414 0l11-11A1 1 0 0 0 15.793.293L5.5 10.586Z</StreamGeometry>
|
|
<x:Double x:Key="CheckBoxMinHeight">32</x:Double>
|
|
|
|
<ControlTheme x:Key="{x:Type CheckBox}" TargetType="CheckBox">
|
|
<Setter Property="Padding" Value="8,0,0,0" />
|
|
<Setter Property="HorizontalAlignment" Value="Left" />
|
|
<Setter Property="VerticalAlignment" Value="Center" />
|
|
<Setter Property="HorizontalContentAlignment" Value="Left" />
|
|
<Setter Property="VerticalContentAlignment" Value="Center" />
|
|
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
|
|
<Setter Property="MinHeight" Value="{DynamicResource CheckBoxMinHeight}" />
|
|
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundUnchecked}" />
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundUnchecked}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushUnchecked}" />
|
|
<Setter Property="Template">
|
|
<ControlTemplate>
|
|
<Grid x:Name="RootGrid" ColumnDefinitions="20,*">
|
|
<Border x:Name="PART_Border"
|
|
Grid.ColumnSpan="2"
|
|
Background="{TemplateBinding Background}"
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
CornerRadius="{TemplateBinding CornerRadius}" />
|
|
|
|
<Grid VerticalAlignment="Top" Height="{DynamicResource CheckBoxMinHeight}">
|
|
<Border x:Name="NormalRectangle"
|
|
BorderBrush="{DynamicResource CheckBoxCheckBackgroundStrokeUnchecked}"
|
|
Background="{DynamicResource CheckBoxCheckBackgroundFillUnchecked}"
|
|
BorderThickness="{DynamicResource CheckBoxBorderThemeThickness}"
|
|
CornerRadius="{TemplateBinding CornerRadius}"
|
|
UseLayoutRounding="False"
|
|
Height="20"
|
|
Width="20" />
|
|
|
|
<Viewbox UseLayoutRounding="False">
|
|
<Panel>
|
|
<Panel Height="16" Width="16" />
|
|
<Path x:Name="CheckGlyph"
|
|
Opacity="0"
|
|
Fill="{DynamicResource CheckBoxCheckGlyphForegroundUnchecked}"
|
|
Stretch="Uniform"
|
|
VerticalAlignment="Center"
|
|
FlowDirection="LeftToRight" />
|
|
</Panel>
|
|
</Viewbox>
|
|
</Grid>
|
|
<ContentPresenter x:Name="PART_ContentPresenter"
|
|
ContentTemplate="{TemplateBinding ContentTemplate}"
|
|
Content="{TemplateBinding Content}"
|
|
Margin="{TemplateBinding Padding}"
|
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
|
TextWrapping="Wrap"
|
|
Grid.Column="1" />
|
|
</Grid>
|
|
</ControlTemplate>
|
|
</Setter>
|
|
|
|
<Style Selector="^ /template/ ContentPresenter#PART_ContentPresenter">
|
|
<Setter Property="RecognizesAccessKey" Value="True" />
|
|
</Style>
|
|
|
|
<!-- Unchecked PointerOver State -->
|
|
<Style Selector="^:pointerover">
|
|
<Style Selector="^ /template/ ContentPresenter#PART_ContentPresenter">
|
|
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundUncheckedPointerOver}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Border#PART_Border">
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundUncheckedPointerOver}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushUncheckedPointerOver}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Border#NormalRectangle">
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeUncheckedPointerOver}" />
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillUncheckedPointerOver}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Path#CheckGlyph">
|
|
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundUncheckedPointerOver}" />
|
|
</Style>
|
|
</Style>
|
|
|
|
<!-- Unchecked Pressed State -->
|
|
<Style Selector="^:pressed">
|
|
<Style Selector="^ /template/ ContentPresenter#PART_ContentPresenter">
|
|
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundUncheckedPressed}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Border#PART_Border">
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundUncheckedPressed}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushUncheckedPressed}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Border#NormalRectangle">
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeUncheckedPressed}" />
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillUncheckedPressed}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Path#CheckGlyph">
|
|
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundUncheckedPressed}" />
|
|
</Style>
|
|
</Style>
|
|
|
|
<!-- Unchecked Disabled state -->
|
|
<Style Selector="^:disabled">
|
|
<Style Selector="^ /template/ ContentPresenter#PART_ContentPresenter">
|
|
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundUncheckedDisabled}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Border#PART_Border">
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundUncheckedDisabled}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushUncheckedDisabled}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Border#NormalRectangle">
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeUncheckedDisabled}" />
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillUncheckedDisabled}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Path#CheckGlyph">
|
|
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundUncheckedDisabled}" />
|
|
</Style>
|
|
</Style>
|
|
|
|
<Style Selector="^:checked">
|
|
<!-- Checked Normal State -->
|
|
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundChecked}" />
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundChecked}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushChecked}" />
|
|
|
|
<Style Selector="^ /template/ Border#NormalRectangle">
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundFillChecked}" />
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillChecked}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Path#CheckGlyph">
|
|
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundChecked}" />
|
|
<Setter Property="Data" Value="{StaticResource CheckMarkPathData}" />
|
|
<Setter Property="Width" Value="9" />
|
|
<Setter Property="Opacity" Value="1" />
|
|
</Style>
|
|
|
|
<!-- Checked PointerOver State -->
|
|
<Style Selector="^:pointerover">
|
|
<Style Selector="^ /template/ ContentPresenter#PART_ContentPresenter">
|
|
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundCheckedPointerOver}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Border#PART_Border">
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundCheckedPointerOver}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushCheckedPointerOver}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Border#NormalRectangle">
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeCheckedPointerOver}" />
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillCheckedPointerOver}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Path#CheckGlyph">
|
|
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundCheckedPointerOver}" />
|
|
</Style>
|
|
</Style>
|
|
|
|
<!-- Checked Pressed State -->
|
|
<Style Selector="^:pressed">
|
|
<Style Selector="^ /template/ ContentPresenter#PART_ContentPresenter">
|
|
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundCheckedPressed}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Border#PART_Border">
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundCheckedPressed}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushCheckedPressed}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Border#NormalRectangle">
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeCheckedPressed}" />
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillCheckedPressed}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Path#CheckGlyph">
|
|
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundCheckedPressed}" />
|
|
</Style>
|
|
</Style>
|
|
|
|
<!-- Checked Disabled State -->
|
|
<Style Selector="^:disabled">
|
|
<Style Selector="^ ContentPresenter#PART_ContentPresenter">
|
|
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundCheckedDisabled}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Border#PART_Border">
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundCheckedDisabled}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushCheckedDisabled}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Border#NormalRectangle">
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeCheckedDisabled}" />
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillCheckedDisabled}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Path#CheckGlyph">
|
|
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundCheckedDisabled}" />
|
|
</Style>
|
|
</Style>
|
|
</Style>
|
|
|
|
<Style Selector="^:indeterminate">
|
|
<!-- Indeterminate Normal State -->
|
|
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundIndeterminate}" />
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundIndeterminate}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushIndeterminate}" />
|
|
|
|
<Style Selector="^ /template/ Border#NormalRectangle">
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeIndeterminate}" />
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillIndeterminate}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Path#CheckGlyph">
|
|
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundIndeterminate}" />
|
|
<Setter Property="Data" Value="M1536 1536v-1024h-1024v1024h1024z" />
|
|
<Setter Property="Width" Value="7" />
|
|
<Setter Property="Opacity" Value="1" />
|
|
</Style>
|
|
|
|
<!-- Indeterminate PointerOver State -->
|
|
<Style Selector="^:pointerover">
|
|
<Style Selector="^ /template/ ContentPresenter#PART_ContentPresenter">
|
|
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundIndeterminatePointerOver}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Border#PART_Border">
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundIndeterminatePointerOver}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushIndeterminatePointerOver}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Border#NormalRectangle">
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeIndeterminatePointerOver}" />
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillIndeterminatePointerOver}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Path#CheckGlyph">
|
|
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundIndeterminatePointerOver}" />
|
|
</Style>
|
|
</Style>
|
|
|
|
<!-- Indeterminate Pressed State -->
|
|
<Style Selector="^:pressed">
|
|
<Style Selector="^ /template/ ContentPresenter#PART_ContentPresenter">
|
|
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundIndeterminatePressed}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Border#PART_Border">
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundIndeterminatePressed}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushIndeterminatePressed}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Border#NormalRectangle">
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeIndeterminatePressed}" />
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillIndeterminatePressed}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Path#CheckGlyph">
|
|
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundIndeterminatePressed}" />
|
|
</Style>
|
|
</Style>
|
|
|
|
<!-- Indeterminate Disabled State -->
|
|
<Style Selector="^:disabled">
|
|
<Style Selector="^ /template/ ContentPresenter#PART_ContentPresenter">
|
|
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundIndeterminateDisabled}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Border#PART_Border">
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxBackgroundIndeterminateDisabled}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrushIndeterminateDisabled}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Border#NormalRectangle">
|
|
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeIndeterminateDisabled}" />
|
|
<Setter Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillIndeterminateDisabled}" />
|
|
</Style>
|
|
|
|
<Style Selector="^ /template/ Path#CheckGlyph">
|
|
<Setter Property="Fill" Value="{DynamicResource CheckBoxCheckGlyphForegroundIndeterminateDisabled}" />
|
|
</Style>
|
|
</Style>
|
|
</Style>
|
|
</ControlTheme>
|
|
</ResourceDictionary>
|
|
|