How can a DataTrigger change the visibility of stackpanel, based on a binded string? I have the following Xaml
<StackPanel HorizontalAlignment="Right" 
            Orientation="Horizontal" 
            Grid.Column="1"
            Background="#FF7a7a7a">
    <StackPanel.Style>
        <Style TargetType="{x:Type StackPanel}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding SearchText}" Value="">
                    <Setter Property="Visibility" Value="Hidden"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </StackPanel.Style>
    Content....
   </StackPanel>
I Know that SearchText gets updates and binds properly outside the StackPanel 
Could somebody point me in the right direction?
This:
<DataTrigger Binding="{Binding SearchText}" Value="">
   <Setter Property="Visibility" Value="Hidden"/>
</DataTrigger>
will work for empty string (""), however it will not work for null.
Add another DataTrigger for the null case:
<DataTrigger Binding="{Binding SearchText}" Value="{x:Null}">
   <Setter Property="Visibility" Value="Hidden"/>
</DataTrigger>
                        Correct using String.Empty in XAML:
xmlns:sys="clr-namespace:System;assembly=mscorlib"
...
<DataTrigger Binding="{Binding SearchText}" Value="{x:Static sys:String.Empty}">
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With