Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escaping commas inside a Pack URI data binding (quick question)

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?

like image 266
Nick Udell Avatar asked Mar 16 '26 15:03

Nick Udell


1 Answers

Try putting the FallbackValue within single quotes

Source="{Binding Path=Image, FallbackValue='pack://application:,,,/checkerboard.png'}"
like image 58
Michal Ciechan Avatar answered Mar 18 '26 05:03

Michal Ciechan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!