I have a lot of textboxes (100's) and I want to style them such that a part of the textbox is certain color and the other in certain.
The above image states what I need. The asterisk to be Red in color.
I have achieved this by using this code
<TextBox.Header>
<TextBlock >
<Run >Card Number</Run><Run Foreground="Red">*</Run>
</TextBlock>
</TextBox.Header>
But I have too many textboxes can I write a style to achieve this? As the content of the header is dynamic I was wondering how can I do this?
Alright achieved this by creating the below styling.
<Style x:Key="mandatoryTextBox" TargetType="TextBox">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock>
<Run Text="{Binding}"></Run><Run Foreground="Red">*</Run>
</TextBlock>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.