Загрузка стиля WPF из файла ресурсов

Я пытаюсь загрузить стиль WPF из другого файла на самом деле из библиотеки настраиваемых элементов управления WPF , но мне не удается загрузить вот мое решение.

Решение содержит два проекта

  1. WpfTestControls типа WPF Custom Control Library

  2. WpfTestApp типа WPF Application Library, имеющего ссылку на WpfTestControls

MainWindow.xaml из библиотеки приложений WPF

<Window.Resources>
    <Style x:Key="TempStyle" TargetType="{x:Type TextBox}">
        <Setter Property="BorderBrush" Value="Green"/>
    </Style>
</Window.Resources>
<Grid>
    <TextBox Height="50px" Width="100px" Style="{DynamicResource TempStyle}"/>
</Grid>

Generic.xaml из WPF Библиотека настраиваемых элементов управления

<ResourceDictionary
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="/WpfTestControls;component/TextBoxStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>

TextBoxStyle.xaml из библиотеки настраиваемых элементов управления WPF

<ResourceDictionary 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="TempStyle" TargetType="{x:Type TextBox}">
    <Setter Property="BorderBrush" Value="Green"/>
</Style>

Мой файл AssemblyInfo.cs содержит следующее

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page, 
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page, 
// app, or any theme specific resource dictionaries))]

Но все же мне не удается загрузить стиль. Если я использую не Generic.xaml, все работает нормально, например, следующий код работает должным образом

<Window x:Class="WpfTestApp.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">

<Window.Resources>
    <Style x:Key="TempStyle" TargetType="{x:Type TextBox}">
        <Setter Property="BorderBrush" Value="Green"/>
    </Style>
</Window.Resources>
<Grid>
    <TextBox Height="50px" Width="100px" Style="{StaticResource TempStyle}"/>
</Grid>

Что я делаю не так? Заранее спасибо

5
задан Robob 14 October 2011 в 07:36
поделиться