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

1

5

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).

Eurhythmy answered 24/2, 2015 at 21:2 Comment(0)
P
10

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}}"/>
Pressmark answered 24/2, 2015 at 21:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.