views:

16

answers:

1

Hi, I'm binding an Image control to a value set at runtime, but I want to set the FallbackValue to a resource named "checkerboard.png".

As Converters aren't applied to FallbackValues I need to use the Pack notation, which leaves me with the following XAML:

<Image x:Name="imgButton" 
    Height="{Binding Path=Height}" 
    Width="{Binding Path=Width}" 
    Stretch="Fill" 
    Source="{Binding Path=Image, FallbackValue=pack://application:,,,/checkerboard.png}"/>

But when I go to build, the compiler has issues with the commas inside the fallbackvalue, giving the following error:

Markup extensions require a single '=' between name and value, and a single ',' between constructor parameters and name/value pairs. The arguments ' Path=Image, FallbackValue=pack://application:,,,/checkerboard.png}' are not valid.

Is there an escape character I can use to force the compiler to accept the commas, or is there another way around this?

+1  A: 

Try putting the FallbackValue within single quotes

Source="{Binding Path=Image, FallbackValue='pack://application:,,,/checkerboard.png'}"
LnDCobra
That's excellent, thanks
Nick Udell