為了提高樣式的重用性,統一配置管理。web將樣式寫成通用的css,然后在頁面中調用css。同樣,wpf同樣有這樣的機制。其中有一個全局控制的地方,那就是在app.xaml中引用樣式。 方法如下:
<Application x:Class="WpfStudy.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<Style x:Key="Style" Resources="SimpleStyle.xaml"></Style>
</Application.Resources>
</Application>
其中,Style必須給key賦值,否則會報如下錯誤:
Error 1 All objects added to an IDictionary must have a Key attribute or some other type of key associated with them. Line 8 Position 14. E:\T程序own-源代碼\BIZ\Biz_WPF\MIS\MIS\App.xaml 8 14 MIS
