- 1 year ago
If else statement with image in xaml vb
Comment
1 / 1
Here is an example of using an If
-Else
statement with an image in XAML VB:
xaml<Grid>
<Image Source="Images\default.png" />
<TextBlock Text="Welcome!" FontSize="24" FontWeight="Bold"
VerticalAlignment="Center" HorizontalAlignment="Center"
Foreground="White">
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsAuthenticated}" Value="True">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
In this example, the Image
control is always visible and displays a default image. The TextBlock
control displays a welcome message if the IsAuthenticated
property is True
, and is hidden if the property is False
. This is achieved using a DataTrigger
in the style of the TextBlock
control.