W
Wonko the Sane
Hello,
I have a custom control, and want to derive a second control from that
control.
public class CustomButton : Button
{
}
public class SpecialCustomButton : CustomButton
{
}
I'd like to use the same base ControlTemplate for both controls, updating
the template used for the Content in the "special" control. However, I can't
seem to figure out how to "share" the ControlTemplate.
In CustomButton.generic.xaml, I define the template:
<ControlTemplate x:Key="templateCustomButton"
TargetType="{x:Type local:CustomButton}}">
<!-- Definitions Here -->
</ControlTemplate>
<Style TargetType="{x:Type local:CustomButton}">
<Setter Property="Template"
Value="{StaticResource templateCustomButton}" />
</Style>
I try to reference the same control template in
SpecialCustomButton.generic.xaml
<Style TargetType="{x:Type local:SpecialCustomButton}">
<Setter Property="Template"
Value="{DynamicResource templateCustomButton}" />
</Style>
However, the special control never shows up on my panel.
Is there a way to do what I'm attempting to do, or do I have to create a new
ControlTemplate and bind every single property again?
Thanks.
WtS
I have a custom control, and want to derive a second control from that
control.
public class CustomButton : Button
{
}
public class SpecialCustomButton : CustomButton
{
}
I'd like to use the same base ControlTemplate for both controls, updating
the template used for the Content in the "special" control. However, I can't
seem to figure out how to "share" the ControlTemplate.
In CustomButton.generic.xaml, I define the template:
<ControlTemplate x:Key="templateCustomButton"
TargetType="{x:Type local:CustomButton}}">
<!-- Definitions Here -->
</ControlTemplate>
<Style TargetType="{x:Type local:CustomButton}">
<Setter Property="Template"
Value="{StaticResource templateCustomButton}" />
</Style>
I try to reference the same control template in
SpecialCustomButton.generic.xaml
<Style TargetType="{x:Type local:SpecialCustomButton}">
<Setter Property="Template"
Value="{DynamicResource templateCustomButton}" />
</Style>
However, the special control never shows up on my panel.
Is there a way to do what I'm attempting to do, or do I have to create a new
ControlTemplate and bind every single property again?
Thanks.
WtS