I just implemented something similar in our project, it will be static, though - I'm not sure what you need. You can change the contents of the shortcut as often as you need, but it will always be red * at the end. I added style to a project like this
<Style x:Key="RequiredFieldLabel" TargetType="{x:Type Label}"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding}" /> <TextBlock Text="*" Foreground="red" /> </StackPanel> </DataTemplate> </Setter.Value> </Setter> </Style>
You can then use this style on the label anywhere in your project.
<Label Content="Enter Name:" Style="{StaticResource RequiredFieldLabel}" />
source share