wpf自定義控制元件新增引用資源

brikoff發表於2018-05-28
<UserControl
    x:Class="HomeDecorationPSD.Presentation.Views.UiWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:local="clr-namespace:HomeDecorationPSD.Presentation.Views"
    mc:Ignorable="d"
    xmlns:system="clr-namespace:System;assembly=mscorlib"       
    >
    <!-- 引入多份資源 -->
    <UserControl.Resources>
        <ResourceDictionary><!-- 重點:需要使用這個標籤來包含多個內容 -->
            <!-- 資源1:來自系統類 -->
            <system:Double x:Key="TabItemWidth">80</system:Double>
            <!-- 資源2:字典類的資源 -->
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Presentation/Resources/ColorResources.xaml"></ResourceDictionary><!-- 專案工程的相對路徑 -->
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>


    <!-- 接下來使用資源 -->


</UserControl>


相關文章