문제

I've successfully added a resource dictionary (containing my theme/collection of styles template resources) to my Window.Resources. This styles each of my windows appropriately. However, when I add the same line:

<ResourceDictionary Source="BureauBlack.xaml" x:Key="BureauBlackKey"/>

To my App.xaml nothing changes.

Edit #1:

<Application x:Class="EventPlanner.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:vm="clr-namespace:EventPlanner.ViewModels"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <vm:ViewModelLocator x:Key="ViewModelLocatorKey"/>
            <ResourceDictionary Source="BureauBlack.xaml" x:Key="BureauBlackKey"/>
        </ResourceDictionary>
    </Application.Resources>
</Application>
도움이 되었습니까?

해결책

You need to add the theme resource dictionary to the MergedDictionaries collection:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="BureauBlack.xaml" />
        </ResourceDictionary.MergedDictionaries>

        <!-- other resources go here -->

        <vm:ViewModelLocator x:Key="ViewModelLocatorKey"/>

    </ResourceDictionary>
</Application.Resources>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top