Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set the FallbackValue for a Binding on UIElement.Margin?

Consider the following bit of code:

<UserControl x:Name=root>
....
    <TextBlock Text="Hello World" Margin="{Binding ElementName=root, Path=LeftButtonMargin}"/>
....
</UserControl>

Now, what is the syntax for setting the FallBackvalue on the Binding?
I've tried some different options already, but I cannot seem to find the correct syntax:

Margin="{Binding ElementName=root, Path=LeftButtonMargin, FallBackValue={}10,10,0,0}"
Margin="{Binding ElementName=root, Path=LeftButtonMargin, FallBackValue={}{10,10,0,0}}"
Margin="{Binding ElementName=root, Path=LeftButtonMargin, FallBackValue={}"10,10,0,0"}"

Or is this not possible at all? Basically, I need these values at design time...

like image 367
RoelF Avatar asked Nov 12 '12 15:11

RoelF


2 Answers

More simple: use single quotes

Margin="{Binding ElementName=root, Path=LeftButtonMargin, FallBackValue='10,10,0,0'}"
like image 175
Sergey Avatar answered Sep 22 '22 00:09

Sergey


Hopefully works,

<UserControl.Resources>
 <Thickness x:Key="MyMargin" Bottom="5" Top="10">

 </Thickness>
<UserControl.Resources>


<TextBlock Text="Hello World" 
Margin="{Binding ...,FallBackValue={StaticResource MyMargin}}"/>
like image 45
Davut Gürbüz Avatar answered Sep 20 '22 00:09

Davut Gürbüz