Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CheckBox Windows 10 Style #3534

Merged
merged 4 commits into from
Jan 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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