Ok, so here is my XAML:
<TextBlock Text="{Binding Path=InstanceName}"></TextBlock>
If InstanceName
is null or an empty string, I want Visibility="Collapsed"
. Otherwise I want Visibility="Visible"
. How would I do that?
Ok, so here is my XAML:
<TextBlock Text="{Binding Path=InstanceName}"></TextBlock>
If InstanceName
is null or an empty string, I want Visibility="Collapsed"
. Otherwise I want Visibility="Visible"
. How would I do that?
Ok, so this is close with PyBinding:
I need to replace IsNotNull with something that means IsNotNullOrEmpty, but I'm getting closer.
You could use a ValueConverter:
with the following codebehind:
If you are inside a (Data-)Template you can use Triggers for that.
Otherwise, the MVVM-Pattern or a ValueConverter will help you.
By putting an extra property in your viewmodel that you can bind the Visibility attribute to:
Then add a DataTrigger to check the value is null and change visibility using Setter. This is the simple method which iam using.