I make a textbox. It is highlighted when it is focused. User inputs text in TextBox and code tests what users enter. If input data is not correct then I want this TextBox be handled by BlurEffect(It wtites in XAML):
<Setter Property="Effect">
<Setter.Value>
<BlurEffect Opacity="1" Color="Red" BlurRadius="30"/>
</Setter.Value>
This code catches if input data is not correct:
private void Filter_textBox_KeyUp(object sender, KeyEventArgs e)
{
string str=Filter_textBox.Text;
if (str == "bbb")
{
Filter_textBox.BitmapEffect = null;
Filter_textBox.Foreground = Brushes.Black;
}
else
//<BlurEffect Opacity="1" Color="Red" BlurRadius="30"/>
And I want to trigger “BlutEffect” in case of “else”.
How to do it? Is it real?
This does exactly what you’re trying to do. But this is not a good practice. You can achieve the same result by using a
DataTrigger.