How to set a default value on a DataTemplate in a Grid Application? RRS feed

  • Question

  • When I was using WPF, I can set a dataTemplate doing this:

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

    And doing this in a Grid Application does not work, it throws me: The attachable property triggers was not found in style. How can I solve it?

    Thanks a lot!

    Sunday, April 8, 2012 4:44 AM


  • Oscar,

    There are not DataTriggers in XAML for Metro Style applications.

    You can use value converter to coalesce null into default image which can be set as ConverterParameter if you want to set it from XAML.

    - ngm

    Sunday, April 8, 2012 5:50 AM