Skip to content

Commit

Permalink
Merge pull request #3534 from timunie/CheckBoxWin10Style
Browse files Browse the repository at this point in the history
CheckBox Windows 10 Style
  • Loading branch information
punker76 authored Jan 6, 2020
2 parents 6700d98 + db4d750 commit 81b2d31
Show file tree
Hide file tree
Showing 14 changed files with 3,110 additions and 129 deletions.
4 changes: 2 additions & 2 deletions src/Directory.Build.Props
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
</ItemGroup>

<ItemGroup>
<None Remove="**\*.png;**\*.jpg;**\*.ico" />
<Resource Include="**\*.png;**\*.jpg;**\*.ico" />
<None Remove="**\*.png;**\*.jpg;**\*.ico;**\*.ttf" />
<Resource Include="**\*.png;**\*.jpg;**\*.ico;**\*.ttf" />
</ItemGroup>

<!-- SourceLink -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,28 +345,71 @@

<StackPanel Grid.Row="1"
Grid.Column="2"
HorizontalAlignment="Center">
<Label Content="Checkbox" Style="{DynamicResource DescriptionHeaderStyle}" />
<CheckBox Margin="{StaticResource ControlMargin}" Content="_Enabled" />
<CheckBox Margin="{StaticResource ControlMargin}"
Content="Enabled"
IsChecked="True" />
<CheckBox Margin="{StaticResource ControlMargin}"
Content="Enabled"
IsChecked="{x:Null}"
IsThreeState="True" />
<CheckBox Margin="{StaticResource ControlMargin}"
Content="Disabled"
IsEnabled="False" />
<CheckBox Margin="{StaticResource ControlMargin}"
Content="Disabled"
IsChecked="True"
IsEnabled="False" />
<CheckBox Margin="{StaticResource ControlMargin}"
Content="Disabled"
IsChecked="{x:Null}"
IsEnabled="False"
IsThreeState="True" />
HorizontalAlignment="Center"
UseLayoutRounding="True">
<StackPanel>
<StackPanel.Resources>
<Style BasedOn="{StaticResource MahApps.Styles.CheckBox.Win10}" TargetType="{x:Type CheckBox}">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="IsChecked={0}, IsEnabled={1}">
<Binding Path="IsChecked"
RelativeSource="{RelativeSource AncestorType={x:Type CheckBox}}"
TargetNullValue="Null" />
<Binding Path="IsEnabled" RelativeSource="{RelativeSource AncestorType={x:Type CheckBox}}" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="Margin" Value="{StaticResource ControlMargin}" />
</Style>
</StackPanel.Resources>

<Label Content="Checkbox Win10 Style" Style="{DynamicResource DescriptionHeaderStyle}" />
<CheckBox IsChecked="False" IsEnabled="True" />
<CheckBox IsChecked="False" IsEnabled="False" />
<CheckBox IsChecked="True" IsEnabled="False" />
<CheckBox IsChecked="True" IsEnabled="True" />
<CheckBox IsChecked="{x:Null}" IsEnabled="True" />
<CheckBox IsChecked="{x:Null}" IsEnabled="False" />
</StackPanel>

<StackPanel>
<StackPanel.Resources>
<Style BasedOn="{StaticResource MahApps.Styles.CheckBox}" TargetType="{x:Type CheckBox}">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="IsChecked={0}, IsEnabled={1}">
<Binding Path="IsChecked"
RelativeSource="{RelativeSource AncestorType={x:Type CheckBox}}"
TargetNullValue="Null" />
<Binding Path="IsEnabled" RelativeSource="{RelativeSource AncestorType={x:Type CheckBox}}" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="Margin" Value="{StaticResource ControlMargin}" />
</Style>
</StackPanel.Resources>

<Label Content="Checkbox" Style="{DynamicResource DescriptionHeaderStyle}" />
<CheckBox IsChecked="False" IsEnabled="True" />
<CheckBox IsChecked="False" IsEnabled="False" />
<CheckBox IsChecked="True" IsEnabled="False" />
<CheckBox IsChecked="True" IsEnabled="True" />
<CheckBox IsChecked="{x:Null}" IsEnabled="True" />
<CheckBox IsChecked="{x:Null}" IsEnabled="False" />
</StackPanel>
</StackPanel>

<StackPanel Grid.Row="1"
Expand Down
Binary file added src/MahApps.Metro/Assets/segmdl2.ttf
Binary file not shown.
33 changes: 33 additions & 0 deletions src/MahApps.Metro/Controls/FontIcon.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Windows;

namespace MahApps.Metro.Controls
{
/// <summary>
/// Represents an icon that uses a glyph from the specified font.
/// </summary>
public class FontIcon : IconElement
{
/// <summary>Identifies the <see cref="Glyph"/> dependency property.</summary>
public static readonly DependencyProperty GlyphProperty
= DependencyProperty.Register(
nameof(Glyph),
typeof(string),
typeof(FontIcon),
new FrameworkPropertyMetadata(string.Empty));

/// <summary>
/// Gets or sets the character code that identifies the icon glyph.
/// </summary>
/// <returns>The hexadecimal character code for the icon glyph.</returns>
public string Glyph
{
get { return (string)this.GetValue(GlyphProperty); }
set { this.SetValue(GlyphProperty, value); }
}

static FontIcon()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(FontIcon), new FrameworkPropertyMetadata(typeof(FontIcon)));
}
}
}
Loading

0 comments on commit 81b2d31

Please sign in to comment.