WPF样式引用
为了提高样式的重用性,统一配置管理。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

浙公网安备 33010602011771号