WPF样式引用

时间:2014-12-11 15:24:43   收藏:0   阅读:348

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

原文:http://www.cnblogs.com/crazylight/p/4157594.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!