wpf - DataTriggers : How it works -
i want implement datatrigger say, textbox1. when text inside textbox1 "abc" want display "data matched!" in textbox say, textbox2. have written below xaml code not working. getting below error message.
'text' member not valid because not have qualifying type name xaml code is:
<window x:class="controltemplatedemo.animation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:system;assembly=mscorlib" title="animation" height="300" width="607"> <grid> <border background="white"> <stackpanel margin="30" horizontalalignment="left" width="500" height="209"> <textbox name="textbox1"> <textbox.triggers> <datatrigger binding="{binding path=text}"> <datatrigger.value> <sys:string>abc</sys:string> </datatrigger.value> <setter targetname="textbox2" property="text" value="data matched!"/> </datatrigger> </textbox.triggers> </textbox> <textbox name="textbox2"> </textbox> </stackpanel> </border> </grid> </window> is there problem in binding?
thanks, hemant
you need give datatrigger in style second textbox
something like:
<stackpanel> <textbox x:name="inputbox" /> <textbox margin="0 25 0 0"> <textbox.style> <style targettype="{x:type textbox}"> <setter property="text" value="no match found" /> <style.triggers> <datatrigger binding="{binding elementname=inputbox, path=text}" value="abc"> <setter property="text" value="match found" /> </datatrigger> </style.triggers> </style> </textbox.style> </textbox> </stackpanel> textbox.triggers not support datatrigger. i'd guess it's eventtriggers documentation states
on side-note, have bindings in element ends target(as can). way find easier debug at-least personally. if textbox has wrong info instantly check it's binding every binding in xaml file see element has wrong binding ends updating textbox.
Comments
Post a Comment