I have a search box which i am trying to to check if it is empty by using the "hasdata" and if empty return false else return true, but the DataTrigger Binding is not working. can someone point me in the right direction on what i am doing wrong.
code:
public bool hasdata
{
get { 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>
Visibilityto yourhasdataand set the bindingConvertertoBooleanToVisibilityConverterVisible. Next you only need oneTrigger. Use aElementName=searchBox, Path=Textbinding and check ifValue={x:Static sys:String.Empty}and switch the Visibility toHidden. DP or INPC for a property that isnt even needed is just overkill. Oh and do follow @Will 's suggestion to read up on some basics