如何使 BorderThickness 从 WPF 资源键接收其值?

发布于 2024-09-30 14:12:16 字数 505 浏览 2 评论 0原文

我尝试创建 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}" />

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我一直都在从未离去 2024-10-07 14:12:16

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

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

祝你好运!

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

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

Good luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文