Change image using trigger WPF MVVM

<DataTemplate DataType="{x:Type local:TabFileViewModel}">
        <StackPanel Orientation="Horizontal">
              <Grid>
                  <Image x:Name="a" Width="16" Height="16" Margin="3,0" Source="Image\NotFounds.PNG" />
                  <Image x:Name="b" Width="16" Height="16" Margin="3,0" Source="Image\TabFile.PNG" />
                </Grid>
              <TextBlock Text="{Binding Name}" ToolTip="{Binding FullPath}"/>
       </StackPanel>
       <DataTemplate.Triggers>
            <DataTrigger Binding={Binding NotFound} Value="true">
                  <Setter TargetName="a" TargetProperty="Visibility" Value="Visible" />
                  <Setter TargetName="b" TargetProperty="Visibility" Value="Hidden" />
            </DataTrigger>
            <DataTrigger Binding={Binding NotFound} Value="false">
                  <Setter TargetName="a" TargetProperty="Visibility" Value="Hidden" />
                  <Setter TargetName="b" TargetProperty="Visibility" Value="Visible" />
            </DataTrigger>
       </DataTemplate.Triggers>
</DataTemplate>

It's all good I figured it out.

<DataTemplate DataType="{x:Type local:TabFileViewModel}">
       <StackPanel Orientation="Horizontal">
         <Image Width="16" Height="16" Margin="3,0">
             <Image.Style>
                 <Style TargetType="{x:Type Image}">
                 <Style.Triggers>
                      <DataTrigger Binding="{Binding NotFound}" Value="false">
                          <Setter Property="Source" Value="Image\TabFile.PNG"/>
                      </DataTrigger>
                      <DataTrigger Binding="{Binding NotFound}" Value="true">
                          <Setter Property="Source" Value="Image\ErrorTabFile.PNG"/>
                      </DataTrigger>
                   </Style.Triggers>
              </Style>
           </Image.Style>
     </Image>
</DataTemplate> 

Tags:

C#

Wpf

Xaml

Mvvm