我們僅須對兩個地方加一些程式碼,就可使所有的RadControl擁用相的Theme,如此一下不但可使Ap內布景主題一致,設計者亦不需要對每個控件做字型,顏色,大小等等瑣碎的設計。
App.Xaml.cs
public App() { StyleManager.ApplicationTheme = new Windows8Theme(); } static App() { //FontSize Style Windows8Palette.Palette.FontSize = 15; Windows8Palette.Palette.FontSizeS = 14; Windows8Palette.Palette.FontSizeL = 15; Windows8Palette.Palette.FontSizeXL = 20; Windows8Palette.Palette.FontSizeXXL = 24; //FontFamily Style Windows8Palette.Palette.FontFamily = new FontFamily("Segoe UI Light, Microsoft JhengHei, Microsoft YaHei"); Windows8Palette.Palette.FontFamilyLight = new FontFamily("Segoe UI Light, Microsoft JhengHei, Microsoft YaHei"); Windows8Palette.Palette.FontFamilyStrong = new FontFamily("Segoe UI Light, Microsoft JhengHei, Microsoft YaHei"); //Colors Style Windows8Palette.Palette.MainColor = Colors.Black; Windows8Palette.Palette.AccentColor = Colors.Orange; Windows8Palette.Palette.BasicColor = Colors.DarkGray; Windows8Palette.Palette.StrongColor = Colors.Gray; Windows8Palette.Palette.MarkerColor = Colors.LightGray; Windows8Palette.Palette.ValidationColor = Colors.Red; }
App.Xaml
<Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <telerik:Windows8ResourceDictionary/> <telerik:Windows8TouchResourceDictionary/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources>
加入這兩部份程式碼所有的RadControl都會套用成Windows8的Theme,來看看修改後的RadDatePicker,
參考資料:
RadControl For WPF:Windows8 and Windows8Touch colors and fonts
[WPF]快速為WPF換裝 - 使用WPF Themes