--- lang: ja-jp breaks: true --- # MaterialDesignThemes と MahApps を使った WPF .NET Core アプリのデザインをカスタマイズする。 2021-05-27 ## 以下の続き https://hackmd.io/48NKvpelRLefe_4W4EPXPQ <iframe width="100%" height="500" src="https://hackmd.io/48NKvpelRLefe_4W4EPXPQ" frameborder="0"></iframe> ## Styles\_FontSizes.xaml ```xml= <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=System.Runtime"> <sys:Double x:Key="SmallFontSize">14</sys:Double> <sys:Double x:Key="MediumFontSize">16</sys:Double> <sys:Double x:Key="LargeFontSize">20</sys:Double> <sys:Double x:Key="XLargeFontSize">24</sys:Double> </ResourceDictionary> ``` ## App.xaml ```xml= <Application ・・・ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls" ・・・ > <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> ・・・ </ResourceDictionary.MergedDictionaries> ・・・ <Style TargetType="{x:Type Page}"> <Setter Property="TextElement.Foreground" Value="{DynamicResource MaterialDesignBody}" /> <Setter Property="TextElement.FontWeight" Value="Medium" /> <Setter Property="TextElement.FontSize" Value="{DynamicResource SmallFontSize}" /> <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" /> <Setter Property="TextOptions.TextRenderingMode" Value="Auto" /> <Setter Property="Background" Value="{DynamicResource MaterialDesignPaper}" /> <Setter Property="FontFamily" Value="{DynamicResource MaterialDesignFont}" /> <Setter Property="FontFamily" Value="Meiryo UI" /> </Style> <Style TargetType="{x:Type Window}"> <Setter Property="TextElement.Foreground" Value="{DynamicResource MaterialDesignBody}" /> <Setter Property="TextElement.FontWeight" Value="Medium" /> <Setter Property="TextElement.FontSize" Value="{DynamicResource SmallFontSize}" /> <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" /> <Setter Property="TextOptions.TextRenderingMode" Value="Auto" /> <Setter Property="Background" Value="{DynamicResource MaterialDesignPaper}" /> <Setter Property="FontFamily" Value="{DynamicResource MaterialDesignFont}" /> <Setter Property="BorderThickness" Value="1" /> <Setter Property="FontFamily" Value="Meiryo UI" /> </Style> <Style TargetType="{x:Type metro:MetroWindow}"> <Setter Property="TextElement.Foreground" Value="{DynamicResource MaterialDesignBody}" /> <Setter Property="TextElement.FontWeight" Value="Medium" /> <Setter Property="TextElement.FontSize" Value="{DynamicResource SmallFontSize}" /> <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" /> <Setter Property="TextOptions.TextRenderingMode" Value="Auto" /> <Setter Property="Background" Value="{DynamicResource MaterialDesignPaper}" /> <Setter Property="FontFamily" Value="{DynamicResource MaterialDesignFont}" /> <Setter Property="GlowBrush" Value="{DynamicResource AccentColorBrush}" /> <Setter Property="BorderThickness" Value="1" /> <Setter Property="FontFamily" Value="Meiryo UI" /> </Style> <Style TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignRaisedButton}" > <Setter Property="materialDesign:ShadowAssist.ShadowDepth" Value="Depth2" /> <Setter Property="FontFamily" Value="Meiryo UI" /> </Style> <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource MaterialDesignFilledTextBox}"> <Setter Property="materialDesign:HintAssist.Hint" Value="アシストヒント" /> <Setter Property="materialDesign:HintAssist.FloatingScale" Value="0.70" /> <Setter Property="materialDesign:HintAssist.FontFamily" Value="Meiryo UI" /> <Setter Property="materialDesign:TextFieldAssist.TextBoxViewMargin" Value="1 0 1 0" /> <Setter Property="FontSize" Value="{DynamicResource MediumFontSize}" /> <Setter Property="FontFamily" Value="Meiryo UI" /> <Setter Property="materialDesign:ShadowAssist.ShadowDepth" Value="Depth2" /> </Style> <Style TargetType="{x:Type PasswordBox}" BasedOn="{StaticResource MaterialDesignFilledPasswordBox}"> <Setter Property="materialDesign:HintAssist.Hint" Value="アシストヒント" /> <Setter Property="materialDesign:HintAssist.FloatingScale" Value="0.70" /> <Setter Property="materialDesign:HintAssist.FontFamily" Value="Meiryo UI" /> <Setter Property="materialDesign:TextFieldAssist.TextBoxViewMargin" Value="1 0 1 0" /> <Setter Property="FontSize" Value="{DynamicResource MediumFontSize}" /> <Setter Property="FontFamily" Value="Meiryo UI" /> <Setter Property="materialDesign:ShadowAssist.ShadowDepth" Value="Depth2" /> </Style> <Style TargetType="{x:Type DatePicker}" BasedOn="{StaticResource MaterialDesignFilledDatePicker}"> <Setter Property="materialDesign:HintAssist.Hint" Value="アシストヒント" /> <Setter Property="materialDesign:HintAssist.FloatingScale" Value="0.70" /> <Setter Property="materialDesign:HintAssist.FontFamily" Value="Meiryo UI" /> <Setter Property="materialDesign:TextFieldAssist.TextBoxViewMargin" Value="1 0 1 0" /> <Setter Property="FontSize" Value="{DynamicResource MediumFontSize}" /> <Setter Property="FontFamily" Value="Meiryo UI" /> <Setter Property="materialDesign:ShadowAssist.ShadowDepth" Value="Depth2" /> </Style> <Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource MaterialDesignFilledComboBox}"> <Setter Property="materialDesign:HintAssist.Hint" Value="アシストヒント" /> <Setter Property="materialDesign:HintAssist.FloatingScale" Value="0.70" /> <Setter Property="materialDesign:HintAssist.FontFamily" Value="Meiryo UI" /> <Setter Property="materialDesign:TextFieldAssist.TextBoxViewMargin" Value="1 0 1 0" /> <Setter Property="FontSize" Value="{DynamicResource MediumFontSize}" /> <Setter Property="FontFamily" Value="Meiryo UI" /> <Setter Property="materialDesign:ShadowAssist.ShadowDepth" Value="Depth2" /> </Style> ・・・ </ResourceDictionary> </Application.Resources> </Application> ``` ###### tags: `WPF` `MaterialDesignThemes` `MahApps` `.NET Core`