I have the following two buttons in XAML:
Why don't you try adding the value as a StaticResource?
Resources.Add("theMargin", 10);
Then you can get that value like this: