How can I define a variable in XAML?

Try this:

add to the head of the xamlfile

xmlns:System="clr-namespace:System;assembly=mscorlib"

Then Add this to the resource section:

<System:Double x:Key="theMargin">2.35</System:Double>

Lastly, use a thickness on the margin:

<Button Content="Next">
   <Button.Margin>
      <Thickness Top="{StaticResource theMargin}" Left="0" Right="0"
                  Bottom ="{StaticResource theMargin}" />
   </Button.Margin>
</Button>

A lot of system types can be defined this way: int, char, string, DateTime, etc

Note:
You’re right… Had to do some better testing.. changed to code so that it should work

Leave a Comment

tech