如何在c#?
中将字体系列的用户首选项设置为wpf mvvm应用程序答案 0 :(得分:2)
您可以为TargetType窗口创建全局样式 并设置了偏好。
资源:
<Application.Resources>
<Style TargetType="Window" x:Key="WindowStyle">
<Setter Property="FontFamily" Value="{Binding FontFamilyPrefernce}" />
</Style>
</Application.Resources>
视图:
<Window Style="{StaticResource WindowStyle}">
<Grid>
<TextBox />
</Grid>
</Window>
ViewModel:
public SomeViewModel()
{
FontFamilyPrefernce = new FontFamily("Algerian");
}
private FontFamily fontFamilyPrefernce;
public FontFamily FontFamilyPrefernce
{
get {return fontFamilyPrefernce ;}
set
{
fontFamilyPrefernce = value;
OnPropertyChanged("FontFamilyPrefernce");
}
}
希望这会有所帮助..