Jens Borrisholt
Jens Borrisholt

Reputation: 6402

XAML Style common ancestor

I have this style targeting TextBlock

<Style TargetType="TextBlock" x:Key="TahomaBase">
    <Setter Property="FontFamily" Value="Tahoma"/>
    <Setter Property="HorizontalAlignment" Value="Left"/>
    <Setter Property="VerticalAlignment" Value="Center"/>
    <Setter Property="TextWrapping" Value="NoWrap"/>
</Style>

Can I some how change the Target type to a common ancestor for textBox and Combobox in order for me to use the style as a base on both component types?

Upvotes: 0

Views: 81

Answers (1)

Galma88
Galma88

Reputation: 2546

Try this.

<Style TargetType="TextBlock" x:Key="TahomaBase" BasedOn="{StaticResource YourStyleAncestor}">
        <Setter Property="FontFamily" Value="Tahoma" />
        <Setter Property="HorizontalAlignment" Value="Left"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="TextWrapping" Value="NoWrap"/>
</Style>

Upvotes: 1

Related Questions