【问题标题】:How to make the BorderThickness receive its value from a WPF resource key?如何使 BorderThickness 从 WPF 资源键接收其值?
【发布时间】:2010-11-04 12:09:54
【问题描述】:

我尝试如下创建StringInt32 资源,但它不起作用。我收到错误消息,提示无法转换该值。

如果你知道怎么做,请帮忙。

<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}" />

【问题讨论】:

    标签: wpf resources border thickness


    【解决方案1】:

    BorderThickness 的类型是 System.Windows.Thinkness 而不是 Int32

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

    祝你好运!

    【讨论】:

    • 我试过发现Thickness标签是内置的,当我们已经使用两个默认命名空间xmlnsxmln:x时,我们不需要命名空间win。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-01
    • 1970-01-01
    • 2011-05-05
    • 1970-01-01
    • 2022-12-04
    • 1970-01-01
    相关资源
    最近更新 更多