TextBox trigger question
-
Hello I have a textBox which I want to add some "ghost" text on, which is visible whenever the textbox does not have focus. I could do it with codebehind, but since I am new to WPF and XAML I would like to do it all from XAML code, to get some practice. Currently my XAML code looks like this:
<TextBox x:Name="textBoxUsername" Margin="5,5">
<TextBox.Style>
<Style TargetType="TextBox">
<Style.Triggers>
<Trigger Property="IsFocused" Value="false">
<Setter Property="Text" Value="Username"/>
<Setter Property="Foreground" Value="LightGray"/>
<Setter Property="FontStyle" Value="Italic"/>
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>What I would like to do, is add another statement to the trigger so it checks if the text is set by the user. This is where I need help, I cannot figure out what to write, so it checks if the text is set by the user or not. If this is not the right way to solve this, I would be happy to get an Article/blog/something which describes how to do it :) //QzRz
-
Hello I have a textBox which I want to add some "ghost" text on, which is visible whenever the textbox does not have focus. I could do it with codebehind, but since I am new to WPF and XAML I would like to do it all from XAML code, to get some practice. Currently my XAML code looks like this:
<TextBox x:Name="textBoxUsername" Margin="5,5">
<TextBox.Style>
<Style TargetType="TextBox">
<Style.Triggers>
<Trigger Property="IsFocused" Value="false">
<Setter Property="Text" Value="Username"/>
<Setter Property="Foreground" Value="LightGray"/>
<Setter Property="FontStyle" Value="Italic"/>
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>What I would like to do, is add another statement to the trigger so it checks if the text is set by the user. This is where I need help, I cannot figure out what to write, so it checks if the text is set by the user or not. If this is not the right way to solve this, I would be happy to get an Article/blog/something which describes how to do it :) //QzRz
Hi, Here is a blog post I found that might be of use to you: http://swt1962.spaces.live.com/blog/cns!3C6545A442A42401!291.entry[^] Cheers, Daniel
Daniel Vaughan Blog: DanielVaughan.Orpius.com
Company: Outcoder