---
title: "How to set a default value on a DataTemplate?"  
description: "How to set a default value on a DataTemplate?"  
author: "Anonymous User"  
published: 2013-08-16  
updated: 2013-08-17  
canonical: https://www.mindstick.com/forum/1378/how-to-set-a-default-value-on-a-datatemplate  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# How to set a default value on a DataTemplate?

Hi [Mindstick](https://yourviews.mindstick.com/view/84668/how-mindstick-is-used-for-marketing-purposes)!

Can you see this tag:

<[Image Source](https://www.mindstick.com/forum/34428/how-to-remove-image-source-from-html-content)="{[Binding](https://www.mindstick.com/blog/146/dynamic-binding-in-c-sharp) Image}" Stretch="UniformToFill"/>

But below? What I'm [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) to do is, when the Image is null, set another [default](https://www.mindstick.com/interview/12771/what-is-the-importance-of-default-resources) image. Is this possible?

<!-- Grid-appropriate 250 pixel square item [template](https://www.mindstick.com/blog/282/creating-custom-template-in-joomla) as seen in the GroupedItemsPage and ItemsPage -->

<DataTemplate x:Key="Standard250x250ItemTemplate">

<Grid HorizontalAlignment="Left" Width="320" Height="240">

<Border [Background](https://www.mindstick.com/articles/65/how-to-change-background-color-of-tab-control-in-c-sharp)="{StaticResource ListViewItemPlaceholderRectBrush}">

<Image Source="{Binding Image}" Stretch="UniformToFill"/>

</Border>

<StackPanel VerticalAlignment="Bottom" Background="{StaticResource ListViewItemOverlayBackgroundBrush}">

<TextBlock Text="{Binding ShortTitle}" Foreground="{StaticResource ListViewItemOverlayTextBrush}" Style="{StaticResource TitleTextStyle}" Height="48" [Margin](https://answers.mindstick.com/qa/104990/what-is-a-margin-call)="15,0,15,0"/>

</StackPanel>

</Grid>

</DataTemplate>

Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)

## Replies

### Reply by shreesh chandra shukla

Hi!

Add a Style with a DataTrigger. e.g. something like

```
<Image Stretch="UniformToFill">    
<Image.Style>         <Style TargetType="Image">            
<Setter Property="Source" Value="{Binding Image}"/>            
<Style.Triggers>                
<DataTrigger Binding="{Binding Image}" Value="{x:Null}">                    
<Setter Property="Source" Value="Images/Default.png"/>                
</DataTrigger>            
</Style.Triggers>        
</Style>   
</Image.Style></Image>
```

thanks


---

Original Source: https://www.mindstick.com/forum/1378/how-to-set-a-default-value-on-a-datatemplate

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
