How to make the BorderThickness receive its value from a WPF resource key?
Asked Answered
U

1

6

I try to create String, Int32 resource as below but it doesn't work. I got the error saying that the value can't be converted.

If you know how to do this please help.

<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <sys:Int32 x:Key="MyKey">1</sys:Int32>
</ResourceDictionary>

<Label Content="abb" BorderThickness="{StaticResource MyKey}" />
Ushaushant answered 4/11, 2010 at 12:9 Comment(0)
T
9

The type of BorderThickness is System.Windows.Thinkness not Int32

<Thickness x:Key="MyKey" >1</Thickness>

Good luck!

Telepathist answered 4/11, 2010 at 12:30 Comment(1)
I tried and see that the Thickness tag is built-in and we don't need the namespace win when we already use the two default namespace xmlns and xmln:x. Thank you!Ushaushant

© 2022 - 2024 — McMap. All rights reserved.