user3089816
user3089816

Reputation: 191

textbox styling for all the forms in the project

Here is the code for the Textbox in one of my form(window1.xaml) here i have applied Textbox.style for the textbox, My requirement is i want to apply this same style for all the textboxes in my project all windows(window2.xaml,window3.xaml,.........)

<TextBox Grid.Column="0" MaxLength="1000" x:Name="txtQuestionDesc" HorizontalAlignment="Stretch" TextWrapping="Wrap" AcceptsReturn="True"
             Grid.Row="1"        
             Margin="5,0,0,5" Height="100"  
                     Text="{Binding QuestionText, UpdateSourceTrigger=LostFocus}" >
                    <TextBox.Style>
                        <Style TargetType="TextBox" xmlns:sys="clr-namespace:System;assembly=mscorlib">
                            <Style.Resources>
                                <VisualBrush x:Key="CueBannerBrush" AlignmentX="Left" AlignmentY="Center" Stretch="None">
                                    <VisualBrush.Visual>
                                        <Label Content="Question Description" Foreground="LightGray" HorizontalAlignment="Center" />
                                    </VisualBrush.Visual>
                                </VisualBrush>
                            </Style.Resources>
                            <Style.Triggers>
                                <Trigger Property="Text" Value="{x:Static sys:String.Empty}">
                                    <Setter Property="Background" Value="{StaticResource CueBannerBrush}" />
                                </Trigger>
                                <Trigger Property="Text" Value="{x:Null}">
                                    <Setter Property="Background" Value="{StaticResource CueBannerBrush}" />
                                </Trigger>
                                <Trigger Property="IsKeyboardFocused" Value="True">
                                    <Setter Property="Background" Value="White" />
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </TextBox.Style>
                </TextBox>

Upvotes: 0

Views: 48

Answers (1)

HDD
HDD

Reputation: 161

Add the Style on your App.xaml, it should work

Upvotes: 1

Related Questions