c# - WPF DataTrigger Binding not working -


i have search box trying to check if empty using "hasdata" , if empty return false else return true, datatrigger binding not working. can point me in right direction on doing wrong.

code:

public bool hasdata {     { if (searchbox.text.count() == 0) return false; else return true; } } 

xaml:

<telerik:radwatermarktextbox x:name="searchbox"/> <image source="someimage.png" >     <image.style>         <style targettype="{x:type image}">             <style.triggers>                 <datatrigger binding="{binding path=hasdata}" value="true">                     <setter property="visibility" value="visible"/>                 </datatrigger>                 <datatrigger binding="{binding path=hasdata}" value="false">                     <setter property="visibility" value="hidden"/>                 </datatrigger>             </style.triggers>         </style>     </image.style> </image> 

the ui has no way of being notified when hasdata changed. need either implement inotifypropertychanged interface or make hasdata dependencyproperty.


Comments