Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to create some values which I can use multiple times throughout a XAML file. I have tried (after setting the sys namespace to clr-namespace:System;assembly=mscorlib)

<sys:Double x:Key="value1">12</sys:Double>  


and then using it like this:

CornerRadius="{StaticResource value1}"

but when I run the code I get an error saying " '12' is not a correct value for CornerRadius property" ... i've also tried setting the value to sys:Int32 but I got the same error.

I am doing this completely wrong? Is there a way to achieve this?

Thanks in advance.
Posted

You could do it this way:

<Window.Resources>
    <Style x:Key="BorderStyle" targetType="Border">
            </Style>
</Window.Resources>


and then just use the style.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 22-Jun-11 12:55pm    
Resources is the way to go, my 5.
--SA
Have a look, CornerRadius property is of type CornerRadius


Border.CornerRadius[^]

Corner radius is a structure, instead of double you create CornerRadius structure and assign it. it should work.

CornerRadius[^]
 
Share this answer
 
Comments
jesicka 21-Jun-11 14:01pm    
thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900