I have the following class:
namespace Controls
{
public class DropDownButton : Control
{
public DropDownButton()
{
this.DefaultStyleKey = typeof(DropDownButton);
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
}
}
}
And in XAML:
<Style TargetType="Controls:DropDownButton">
<Setter Property="FontSize" Value="10"/>
<Setter Property="Height" Value="202"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<Button Content="Button1">
<Button.Template>
<ControlTemplate TargetType="Button">
</ControlTemplate>
</Button.Template>
</Button>
</Setter.Value>
</Setter>
<Setter Property="MinWidth" Value="65"/>
</Style>
I have two problems (possibly related): The button in the xaml is not being displayed in the control and the control is not having its OnApplyTemplate() function called at all. The only thing the control seems to be responsive to is setting its dimensions…
The
Templateis lacking itsControlTemplateelement: