1
如何將字體系列的用戶首選項設置爲c#中的wpf mvvm應用程序?將字體系列的用戶首選項設置爲wpf mvvm應用程序
如何將字體系列的用戶首選項設置爲c#中的wpf mvvm應用程序?將字體系列的用戶首選項設置爲wpf mvvm應用程序
您可以爲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>
視圖模型:
public SomeViewModel()
{
FontFamilyPrefernce = new FontFamily("Algerian");
}
private FontFamily fontFamilyPrefernce;
public FontFamily FontFamilyPrefernce
{
get {return fontFamilyPrefernce ;}
set
{
fontFamilyPrefernce = value;
OnPropertyChanged("FontFamilyPrefernce");
}
}
希望這有助於..