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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM