Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display Image with design-time Source in Expression Blend

I have an Image down some controls in a XAML visual tree. I would like to display a design-time image, so that I can check layout, dimensions, etc. Something equivalent to this:

<UserControl.Resources>
    <Something x:Key="DesignSource" Uri="/Image/sourceimage.png"/>
</UserControl.Resources>

<Image
    Source="{Binding RealSource}"
    d:Source="{StaticResource DesignSource}"/>

Where "something" would be some imagesource provider pointing to some image file, and "d:Source" is here just to show my intent: to define different sources at the same time: one for runtime, other for design time.

Usage of DataProviders in XAML or SampleData (Blend) are welcome (I know they exist, but don't know how to include images).

like image 921
heltonbiker Avatar asked Feb 11 '23 20:02

heltonbiker


1 Answers

You could achieve that by setting the Binding's FallbackValue:

<UserControl.Resources>
    <BitmapImage x:Key="DesignSource" UriSource="/Image/sourceimage.png"/>
</UserControl.Resources>

<Image Source="{Binding RealSource, FallbackValue={StaticResource DesignSource}}"/>
like image 111
Clemens Avatar answered Feb 13 '23 21:02

Clemens