First of all, I would like to add custom text blocks to my GUI at the lowest possible cost. For instance:<TextBlock style={StaticRessources myTextBlock}>Text</TextBlock>
Now I have the following frame style:
<Style x:Key="greenBox" TargetType="Border">
<Setter Property="Background" Value="#00FF00"/>
<Setter Property="CornerRadius" Value="10"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="Height" Value="40"/>
<Setter Property="Width" Value="100"/>
</Style>
And I apply it as follows:
<Border Style="{StaticResource greenBox}">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">Custom Text</TextBlock>
</Border>
My problem is that it needs 2 tags, and the properties set in TextBlock will be superfluous. I cannot figure out how to abstract both definitions into one element.
source
share