I have a question about automatic style inheritance.
Basically, I have a superclass for which I would like to define the default style for textboxes and textblocks for classes that derive from it. These styles are based on my default styles as defined in Styles.xaml.
<controls:BaseUserControl.Resources>
<Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource DisplayLabel}">
<Setter Property="Foreground" Value="Black"/>
<Setter Property="Margin" Value="10,0,10,0"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource InputField}">
<Setter Property="Height" Value="30"/>
<Setter Property="Margin" Value="10,0,0,0"></Setter>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"></Setter>
</Style>
</controls:BaseUserControl.Resources>
This class is called DataEntryView
.
Now when I derive from this class, the textblock and textboxes just get their default Windows look, not what I defined here.
<views:DataEntryView.Resources>
<!-- Do I need to add anything here? -->
</views:DataEntryView.Resources>
What is it that I'm forgetting?
Basically, I don't want to explicitly set the Style of every textblock and textbox to some key.