Click here for Japanese page (日本語ページはこちら)
UI control libraries for create WPF window like Visual Studio 2012/2013/2015. MetroRadiance.Fork is forked of MetroRadiance 2.4.0.
Install NuGet package(s).
PM> Install-Package MetroRadiance.Fork
- MetroRadiance.Fork.Core - MetroRadiance core library.
- MetroRadiance.Fork.Chrome - Chrome library for WPF Window.
- MetroRadiance.Fork - WPF custom control library.
- Get system DPI
- Get monitor DPI from monitor handle
- Get window DPI from Visual
- Get window DPI from HwndSource or window handle
using MetroRadiance.Platform;
// Get system dpi.
var systemDpi = DpiHelper.GetDpiForSystem();
// Get monitor dpi.
var monitorDpi = DpiHelper.GetDpiForMonitor(hMonitor);
// Get window dpi from HwndSource.
var hwndSource = (HwndSource)PresentationSource.FromVisual(this);
var windowDpi = hwndSource.GetDpi();
// Get window dpi from window handle.
var windowDpi = DpiHelper.GetDpiForWindow(hWnd);
- Get Windows app theme (
WindowsTheme.Theme
, Light or Dark, only Windows 10) - Get Windows system theme (
WindowsTheme.SystemTheme
, Light or Dark, only Windows 10) - Get Windows accent color (
WindowsTheme.Accent
) - Get Windows highContrast mode (
WindowsTheme.HighContrast
) - Get Windows color prevalence (
WindowsTheme.ColorPrevalence
) - Get Windows transparency (
WindowsTheme.Transparency
) - [v3.0.0-] Get Windows text scale factor (
WindowsTheme.TextScaleFactor
) - Subscribe theme property change event from Windows
using MetroRadiance.Platform;
// Get Windows accent color
var color = WindowsTheme.Accent.Current;
// Subscribe accent color change event from Windows theme.
var disposable = WindowsTheme.Accent.RegisterListener(color =>
{
// apply color to your app.
});
// Unsubscribe color change event.
disposable.Dispose();
using MetroRadiance.Media;
// Get Windows accent color (using MetroRadiance.Platform;)
var rgbColor = WindowsTheme.Accent.Current;
// Convert from RGB to HSV color.
var hsvColor = rgbColor.ToHsv();
hsvColor.V *= 0.8;
// Convert from HSV to RGB color.
var newColor1 = hsvColor.ToRgb();
// [v3.0.0-] Convert from RGB to HSL color.
var hslColor = rgbColor.ToHsv();
hslColor.L *= 0.8;
// [v3.0.0-] Convert from HSL to RGB color.
var newColor2 = hslColor.ToRgb();
// Calculate luminosity from RGB color.
var luminosity = Luminosity.FromRgb(rgbColor);
MetroRadiance.Chrome.WindowChrome
<Window xmlns:chrome="http://schemes.grabacr.net/winfx/2014/chrome">
<chrome:WindowChrome.Instance>
<chrome:WindowChrome />
</chrome:WindowChrome.Instance>
</Window>
MetroRadiance.Chrome.WindowChrome.Top
/.Left
/.Right
/.Bottom
<Window xmlns:chrome="http://schemes.grabacr.net/winfx/2014/chrome">
<chrome:WindowChrome.Instance>
<chrome:WindowChrome>
<chrome:WindowChrome.Top>
<Border Background="DarkRed"
Padding="24,3"
Margin="8,0"
HorizontalAlignment="Right">
<TextBlock Text="any UI elements"
Foreground="White" />
</Border>
</chrome:WindowChrome.Top>
</chrome:WindowChrome>
</chrome:WindowChrome.Instance>
</Window>
// Change theme.
ThemeService.Current.ChangeTheme(Theme.Dark);
// Change theme (sync Windows)
ThemeService.Current.ChangeTheme(Theme.Windows);
// Change Accent
ThemeService.Current.ChangeAccent(Accent.Blue);
// Change accent (sync Windows)
ThemeService.Current.ChangeAccent(Accent.Windows);
// Change accent (from RGB Color)
var accent = Colors.Red.ToAccent();
ThemeService.Current.ChangeAccent(accent);
MetroRadiance defines UWP compatible Color and Brush resources. Naming rule is here (Microsoft site)
You can not use these as ThemeResource
in WPF.
If you use these as DynamicResource
in your controls, the control will work with the theme color.
These resources are enabled by the followings.
-
Define in WPF XAML (App.xaml.cs)
App enables UWP resources using
EnableUwpResoruces()
before callingRegister()
. This method enables UWP resources for the entire app.using MetroRadiance.UI; public partial class App : Application { protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); ThemeService.Current.EnableUwpResoruces(); ThemeService.Current.Register(this, Theme.Windows, Accent.Windows); ...
-
Define in WPF XAML (not App.xaml)
This method enables UWP resources only for the specified object (Window/Control/etc).
- Enable HasThemeResource using
ThemeHelper.HasThemeResources="True"
for Window/Control/etc - Merge at least one UWP resource (.../Themes/UWP/....xaml) defined in MetroRadiance component
<UserControl x:Class="MetroRadiance.Showcase.UI.UwpBrushSamples" ... xmlns:metro="http://schemes.grabacr.net/winfx/2014/controls" metro:ThemeHelper.HasThemeResources="True"> <UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/MetroRadiance;component/Themes/UWP/Dark.xaml" /> </ResourceDictionary.MergedDictionaries> ...
- Enable HasThemeResource using
UWP resoruce files defined in MetroRadiance component
/Themes/UWP/Light.xaml
/Themes/UWP/Dark.xaml
/Themes/UWP/HighContrast.xaml
/Themes/UWP/Accents/Blue.xaml
/Themes/UWP/Accents/Orange.xaml
/Themes/UWP/Accents/Purple.xaml
Your app can reference using the prefix: "pack://application:,,,/MetroRadiance;component/"
.
MetroRadiance defines custom Color and Brush resources.
Naming rule is [ColorName]ColorKey
and [ColorName]BrushKey
.
You can not use these as ThemeResource
in WPF.
If you use these as DynamicResource
in your controls, the control will work with the theme color.
These resources are enabled by the followings.
-
Define in WPF XAML (App.xaml.cs)
App enables the custom color and brush resources using
Register()
. This method enables custom resources for the entire app.using MetroRadiance.UI; public partial class App : Application { protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); ThemeService.Current.Register(this, Theme.Windows, Accent.Windows); ...
-
Define in WPF XAML (not App.xaml)
This method enables custom resources only for the specified object (Window/Control/etc).
- Enable HasThemeResource using
ThemeHelper.HasThemeResources="True"
for Window/Control/etc
<UserControl x:Class="MetroRadiance.Showcase.UI.BrushSamples" ... xmlns:metro="http://schemes.grabacr.net/winfx/2014/controls" metro:ThemeHelper.HasThemeResources="True"> ...
- Enable HasThemeResource using
Custom resoruce files defined in MetroRadiance component
/Themes/Light.xaml
/Themes/Dark.xaml
/Themes/Accents/Blue.xaml
/Themes/Accents/Orange.xaml
/Themes/Accents/Purple.xaml
Your app can reference using the prefix: "pack://application:,,,/MetroRadiance;component/"
.
Table: Theme Color
Color Name | Sample | Color Key | Brush Key |
---|---|---|---|
Theme | Light/Dark | ThemeColorKey | ThemeBrushKey |
Background | Light/Dark | BackgroundColorKey | BackgroundBrushKey |
Border | Light/Dark | BorderColorKey | BorderBrushKey |
Foreground | Light/Dark | ForegroundColorKey | ForegroundBrushKey |
SemiactiveBackground | Light/Dark | SemiactiveBackgroundColorKey | SemiactiveBackgroundBrushKey |
SemiactiveBorder | Light/Dark | SemiactiveBorderColorKey | SemiactiveBorderBrushKey |
SemiActiveForeground | Light/Dark | SemiActiveForegroundColorKey | SemiActiveForegroundBrushKey |
ActiveBackground | Light/Dark | ActiveBackgroundColorKey | ActiveBackgroundBrushKey |
ActiveBorder | Light/Dark | ActiveBorderColorKey | ActiveBorderBrushKey |
ActiveForeground | Light/Dark | ActiveForegroundColorKey | ActiveForegroundBrushKey |
InactiveBackground | Light/Dark | InactiveBackgroundColorKey | InactiveBackgroundBrushKey |
InactiveBorder | Light/Dark | InactiveBorderColorKey | InactiveBorderBrushKey |
InactiveForeground | Light/Dark | InactiveForegroundColorKey | InactiveForegroundBrushKey |
HighlightBackground | Light/Dark | HighlightBackgroundColorKey | HighlightBackgroundBrushKey |
HighlightBorder | Light/Dark | HighlightBorderColorKey | HighlightBorderBrushKey |
HighlightForeground | Light/Dark | HighlightForegroundColorKey | HighlightForegroundBrushKey |
Highlight2Background | Light/Dark | Highlight2BackgroundColorKey | Highlight2BackgroundBrushKey |
Highlight2Border | Light/Dark | Highlight2BorderColorKey | Highlight2BorderBrushKey |
Highlight2Foreground | Light/Dark | Highlight2ForegroundColorKey | Highlight2ForegroundBrushKey |
Highlight3Background | Light/Dark | Highlight3BackgroundColorKey | Highlight3BackgroundBrushKey |
Highlight3Border | Light/Dark | Highlight3BorderColorKey | Highlight3BorderBrushKey |
Highlight3Foreground | Light/Dark | Highlight3ForegroundColorKey | Highlight3ForegroundBrushKey |
LinkForeground | Light/Dark | LinkForegroundColorKey | LinkForegroundBrushKey |
ActiveLinkForeground | Light/Dark | ActiveLinkForegroundColorKey | ActiveLinkForegroundBrushKey |
ValidationError | Light/Dark | ValidationErrorColorKey | ValidationErrorBrushKey |
Table: Accent Color
Color Name | Sample | Color Key | Brush Key |
---|---|---|---|
Accent | Blue/Orange/Purple | AccentColorKey | AccentBrushKey |
AccentHighlight | Blue/Orange/Purple | AccentHighlightColorKey | AccentHighlightBrushKey |
AccentActive | Blue/Orange/Purple | AccentActiveColorKey | AccentActiveBrushKey |
AccentForeground | Blue/Orange/Purple | AccentForegroundColorKey | AccentForegroundBrushKey |
Style definition sample
<Style TargetType="{x:Type Button}">
<Setter Property="Background"
Value="{DynamicResource BackgroundBrushKey}" />
<Setter Property="BorderBrush"
Value="{DynamicResource BorderBrushKey}" />
<Setter Property="Foreground"
Value="{DynamicResource ActiveForegroundBrushKey}" />
<Setter Property="BorderThickness"
Value=".99" />
<Setter Property="Padding"
Value="8,2" />
<Setter Property="FocusVisualStyle"
Value="{DynamicResource {x:Static SystemParameters.FocusVisualStyleKey}}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
Background="{TemplateBinding Background}">
<ContentPresenter x:Name="contentPresenter"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Background"
Value="{DynamicResource ActiveBackgroundBrushKey}" />
<Setter Property="BorderBrush"
Value="{DynamicResource ActiveBorderBrushKey}" />
</Trigger>
<Trigger Property="IsPressed"
Value="True">
<Setter Property="Background"
Value="{DynamicResource AccentBrushKey}" />
<Setter Property="BorderBrush"
Value="{DynamicResource ActiveBorderBrushKey}" />
<Setter Property="Foreground"
Value="{DynamicResource AccentForegroundBrushKey}" />
</Trigger>
<Trigger Property="IsEnabled"
Value="False">
<Setter Property="Background"
Value="{DynamicResource InactiveBackgroundBrushKey}" />
<Setter Property="BorderBrush"
Value="{DynamicResource InactiveBorderBrushKey}" />
<Setter Property="Foreground"
Value="{DynamicResource InactiveForegroundBrushKey}" />
</Trigger>
</Style.Triggers>
</Style>
You can use the standard control styles by merging "/Styles/Controls.xaml"
or "/Styles/Control-styles.xaml"
of MetroRadiance into Application.Resource
etc.
These styles use the colors and brushes defined in MetroRadiance. Therefore, it will be linked to the theme change and color setting change.
"/Styles/Control-styles.xaml"
defines MetroRadiance styles using Keys in MetroRadiance.styles.XXXX format (defined in ver. 3.0 or later) or MetroRadianceXXXXStyleKey format (defined in ver. 2.4 or before).
"/Styles/Controls.xaml"
overrides standard control styles.
"/Styles/Controls.xaml"
also includes MetroRadiance styles are defined by "/Styles/Control-styles.xaml"
.
<Application x:Class="MetroRadiance.Showcase.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="UI/MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MetroRadiance;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MetroRadiance;component/Themes/Dark.xaml" />
<ResourceDictionary Source="pack://application:,,,/MetroRadiance;component/Themes/Accents/Blue.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
<Style TargetType="{x:Type Button}" x:key="MetroRadianceButtonStyleKey">
<Style TargetType="{x:Type Button}" x:Key="CircleButtonStyleKey">
<Style TargetType="{x:Type CheckBox}" x:Key="MetroRadianceCheckBoxStyleKey">
<Style TargetType="{x:Type ComboBox}" x:Key="MetroRadiance.Styles.ComboBox">
<Style TargetType="{x:Type ContextMenu}" x:Key="MetroRadiance.Styles.ContextMenu">
- [v3.1.0-]
<Style TargetType="{x:Type DataGrid}" x:Key="{StaticResource MetroRadiance.Styles.DataGrid}"/>
- [v3.1.0-]
<Style TargetType="{x:Type DataGridColumnHeader}" x:Key="{StaticResource MetroRadiance.Styles.DataGrid.DataGridColumnHeader}"/>
<Style TargetType="{x:Type Expander}" x:Key="MetroRadianceExpanderStyleKey">
<Style x:Key="MetroRadianceFocusVisualStyleKey">
<Style TargetType="{x:Type GroupBox}" x:Key="MetroRadiance.Styles.GroupBox">
<Style TargetType="{x:Type Label}" x:Key="MetroRadiance.Styles.Label">
- [v3.2.0-]
<Style TargetType="{x:Type ListBox}" x:Key="MetroRadiance.Styles.ListBox"/>
- [v3.2.0-]
<Style TargetType="{x:Type ListBoxItem}" x:Key="MetroRadiance.Styles.ListBoxItem"/>
- [v3.2.0-]
<Style TargetType="{x:Type ListView}" x:Key="MetroRadiance.Styles.ListView"/>
- [v3.2.0-]
<Style TargetType="{x:Type ListViewItem}" x:Key="MetroRadiance.Styles.ListViewItem"/>
- [v3.2.0-]
<Style TargetType="{x:Type GridViewColumnHeader}" x:Key="MetroRadiance.Styles.ListView.GridViewColumnHeader"/>
<Style TargetType="{x:Type Menu}" x:Key="MetroRadiance.Styles.Menu">
<Style TargetType="{x:Type MenuItem}" x:Key="MetroRadiance.Styles.MenuItem">
<Style TargetType="{x:Type Separator}" x:Key="MetroRadiance.Styles.Menu.Separator">
<Style TargetType="{x:Type PasswordBox}" x:Key="MetroRadiancePasswordBoxStyleKey">
<Style TargetType="{x:Type RadioButton}" x:Key="MetroRadianceRadioButtonStyleKey">
<Style TargetType="{x:Type ScrollBar}" x:Key="MetroRadianceScrollBarStyleKey">
<Style TargetType="{x:Type TextBox}" x:Key="MetroRadiance.Styles.TextBoxBase">
<Style TargetType="{x:Type ToggleButton}" x:Key="MetroRadianceToggleButtonStyleKey">
<Style TargetType="{x:Type ToolTip}" x:Key="MetroRadianceToolTipStyleKey">
("/Styles/Controls.xaml" includes MetroRadiance styles are defined by "/Styles/Control-styles.xaml")
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource MetroRadianceButtonStyleKey}"/>
<Style TargetType="{x:Type CheckBox}" BasedOn="{StaticResource MetroRadianceCheckBoxStyleKey}"/>
- [v3.0.0-]
<Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource MetroRadiance.Styles.ComboBox}"/>
- [v3.0.0-]
<Style TargetType="{x:Type ContextMenu}" BasedOn="{StaticResource MetroRadiance.Styles.ContextMenu}" x:Key="{x:Type ContextMenu}" />
- [v3.1.0-]
<Style TargetType="{x:Type DataGrid}" BasedOn="{StaticResource MetroRadiance.Styles.DataGrid}"/>
- [v3.1.0-]
<Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MetroRadiance.Styles.DataGrid.DataGridColumnHeader}"/>
<Style TargetType="{x:Type Expander}" BasedOn="{StaticResource MetroRadianceExpanderStyleKey}"/>
<Style BasedOn="{StaticResource MetroRadianceFocusVisualStyleKey}" x:Key="{x:Static SystemParameters.FocusVisualStyleKey}"/>
- [v3.0.0-]
<Style TargetType="{x:Type GroupBox}" BasedOn="{StaticResource MetroRadiance.Styles.GroupBox}"/>
- [v3.0.0-]
<Style TargetType="{x:Type Label}" BasedOn="{StaticResource MetroRadiance.Styles.Label}"/>
- [v3.2.0-]
<Style TargetType="{x:Type ListBox}" BasedOn="{StaticResource MetroRadiance.Styles.ListBox}"/>
- [v3.2.0-]
<Style TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource MetroRadiance.Styles.ListBoxItem}"/>
- [v3.2.0-]
<Style TargetType="{x:Type ListView}" BasedOn="{StaticResource MetroRadiance.Styles.ListView}"/>
- [v3.2.0-]
<Style TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource MetroRadiance.Styles.ListViewItem}"/>
- [v3.2.0-]
<Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource MetroRadiance.Styles.ListView.GridViewColumnHeader}"/>
- [v3.0.0-]
<Style TargetType="{x:Type Menu}" BasedOn="{StaticResource MetroRadiance.Styles.Menu}"/>
- [v3.0.0-]
<Style TargetType="{x:Type Separator}" BasedOn="{StaticResource MetroRadiance.Styles.Menu.Separator}" x:Key="{x:Static MenuItem.SeparatorStyleKey}"/>
- [v3.0.0-]
<Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource MetroRadiance.Styles.MenuItem}"/>
<Style TargetType="{x:Type PasswordBox}" BasedOn="{StaticResource MetroRadiancePasswordBoxStyleKey}"/>
<Style TargetType="{x:Type RadioButton}" BasedOn="{StaticResource MetroRadianceRadioButtonStyleKey}"/>
<Style TargetType="{x:Type ScrollBar}" BasedOn="{StaticResource MetroRadianceScrollBarStyleKey}"/>
- [v3.0.0-]
<Style TargetType="{x:Type TextBoxBase}" BasedOn="{StaticResource MetroRadiance.Styles.TextBoxBase}"/>
- [v3.0.0-]
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBoxBase}}"/>
<Style TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MetroRadianceToggleButtonStyleKey}"/>
<Style TargetType="{x:Type ToolTip}" BasedOn="{StaticResource MetroRadianceToolTipStyleKey}"/>
- [v3.0.0-] AcrylicBlurWindow
- Badge
- BindableRichTextBox
- BindableTextBlock
- BlurWindow
- CaptionButton
- CaptionIcon
- ExpanderButton
- LinkButton
- MetroWindow
- ProgressRing
- PromptComboBox
- PromptTextBox
- ResizeGrip
- SystemButtons
- TabView
- WindowStateToVisibilityConverter
- [v3.0.0-] Int16Rule
- [v3.0.0-] UInt16Rule
- Int32Rule
- [v3.0.0-] UInt32Rule
- [v3.0.0-] Int64Rule
- [v3.0.0-] UInt64Rule
- [v3.0.0-] SingleRule
- [v3.0.0-] DoubleRule
Example for TextBox using UInt16Rule (ushort)
<TextBox xmlns:metro="http://schemes.grabacr.net/winfx/2014/controls">
<TextBox.Text>
<Binding Path="UInt16"
UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<metro:UInt16Rule Min="1"
Max="49" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
Example for TextBox using DoubleRule (dobule).
If you want to use PropertyChanged as UpdateSourceTrigger for DoubleRule and SingleRule, you need to use FrameworkCompatibilityPreferences.KeepTextBoxDisplaySynchronizedWithTextProperty = false;
<TextBox xmlns:metro="http://schemes.grabacr.net/winfx/2014/controls">
<TextBox.Text>
<Binding Path="Double"
UpdateSourceTrigger="LostFocus">
<Binding.ValidationRules>
<metro:Int32Rule Min="-4.9"
Max="9.9" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
Example for TextBox using UInt16Rule (ushort) and a tooltip display of errors
<TextBox xmlns:metro="http://schemes.grabacr.net/winfx/2014/controls">
<TextBox.Text>
<Binding Path="UInt16"
UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<metro:Int32Rule Min="1"
Max="49" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
<TextBox.Style>
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
<Style.Triggers>
<Trigger Property="Validation.HasError"
Value="True">
<Setter Property="ToolTip">
<Setter.Value>
<Binding
Path="(Validation.Errors)[0].ErrorContent"
RelativeSource="{x:Static RelativeSource.Self}" />
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
Example for metro:PromptTextBox using Int32Rule (int)
<metro:PromptTextBox xmlns:metro="http://schemes.grabacr.net/winfx/2014/controls">
<metro:PromptTextBox.Text>
<Binding Path="Int32"
UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<metro:Int32Rule Min="-4"
Max="49" />
</Binding.ValidationRules>
</Binding>
</metro:PromptTextBox.Text>
</metro:PromptTextBox>
The attached properties provided by DataGridProperties are attached properties that allow the element style of DataGridTextColumn / DataGridCheckBoxColumn / DataGridComboBoxColumn to be set to DataGrid. This simplifies the need to set element styles for DataGridTextColumn / DataGridCheckBoxColumn / DataGridComboBoxColumn.
- TextColumnDefaultElementStyle
- TextColumnDefaultEditingElementStyle
- CheckBoxColumnDefaultElementStyle
- CheckBoxColumnDefaultEditingElementStyle
- ComboBoxColumnDefaultElementStyle
- ComboBoxColumnDefaultEditingElementStyle
Example for mrap:DataGridProperties.XXXDefalutElementStyle / mrap:DataGridProperties.XXXDefalutEditingElementStyle
<Window
...
xmlns:metroAP="http://schemes.grabacr.net/winfx/2014/attached-poperties">
<DataGrid
metroAP:DataGridProperties.TextColumnDefaultElementStyle="{DynamicResource My.Styles.DataGridTextColumn.Element}"
metroAP:DataGridProperties.TextColumnDefaultEditingElementStyle="{DynamicResource My.Styles.DataGridTextColumn.EditingElement}"
metroAP:DataGridProperties.CheckBoxColumnDefaultElementStyle="{DynamicResource My.Styles.DataGridCheckBoxColumn.Element}"
metroAP:DataGridProperties.CheckBoxColumnDefaultEditingElementStyle="{DynamicResource My.Styles.DataGridCheckBoxColumn.EditingElement}"
metroAP:DataGridProperties.ComboBoxColumnDefaultElementStyle="{DynamicResource My.Styles.DataGridComboBoxColumn.Element}"
metroAP:DataGridProperties.ComboBoxColumnDefaultEditingElementStyle="{DynamicResource My.Styles.DataGridComboBoxColumn.EditingElement}"
>
<DataGrid.Columns>
<DataGridTextColumn
Header="Id"
Binding="{Binding Id}"/>
<DataGridCheckBoxColumn
Header="CheckBox"
Binding="{Binding Active,UpdateSourceTrigger=PropertyChanged}"
IsThreeState="True"/>
<DataGridComboBoxColumn
Header="ComboBox"
SelectedValueBinding="{Binding Selected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="Name"
SelectedValuePath="Name"
ItemsSource="{StaticResource DataItems}"/>
</DataGrid.Columns>
</DataGrid>
...
The attached properties provided by ListViewProperties are attached properties that allow the style of GridView to be set to ListView. This simplifies the need to set styles for GridView.
- ColumnHeaderDefaultContainerStyle
Example for mrap:ListViewProperties.ColumnHeaderDefaultContainerStyle
<Window
...
xmlns:metroAP="http://schemes.grabacr.net/winfx/2014/attached-poperties">
<ListView
metroAP:ListViewProperties.ColumnHeaderDefaultContainerStyle="{DynamicResource My.Styles.ListView.GridViewColumnHeader}"
>
<ListView.View>
<GridView AllowsColumnReorder="True"
ColumnHeaderToolTip="Employee Information">
<GridViewColumn DisplayMemberBinding="{Binding Id}" Header="Id"/>
<GridViewColumn DisplayMemberBinding="{Binding Name}" Header="Name"/>
</GridView>
</ListView.View>
</ListView>
...
This library is under the MIT License (MIT).