我在主要会议(WPF Application)中建立了一些习俗控制,并对它进行了测试——所有都是ok。 然后,我把这一控制改为单独大会(EB.Controls)。
在启动大会(WPF Application)时,我添加了/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>
But control does not render. Here is the my control 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>
并且:
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();
}
}
我在哪里犯错误?