Я создал пользовательский элемент управления в основной сборке (WPF Application) и протестировал его - все было в порядке.Затем я заменил этот элемент управления на отдельную сборку (EB.Controls).
При загрузке сборки (приложение WPF) я добавил файл /Themes/generic.xaml для импорта моего пользовательского элемента управления:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/EB.Controls;component/HeadButton.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Но контроль не оказывает.Вот мой контрольный XAML:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:EB.Controls" >
<ControlTemplate TargetType="Controls:HeadButton" x:Key="HeadButtonTemplate">
<Border Background="{TemplateBinding Background}"
CornerRadius="0.2"
BorderBrush="White" BorderThickness="1">
<Grid>
<ContentPresenter/>
</Grid>
</Border>
</ControlTemplate >
<Style TargetType="Controls:HeadButton">
<Setter Property="Template" Value="{StaticResource HeadButtonTemplate}"/>
</Style>
</ResourceDictionary>
И .cs:
namespace EB.Controls
{
[TemplateVisualState(Name = VisualStates.MouseOver, GroupName = VisualStates.CommonStates)]
[TemplateVisualState(Name = VisualStates.Normal, GroupName = VisualStates.CommonStates)]
public class HeadButton : Button
{
public HeadButton()
{
DefaultStyleKey = typeof (HeadButton);
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
}
}
Где я допустил ошибку?