gpt4 book ai didi

wpf - WPF 资源中的整数值?

转载 作者:行者123 更新时间:2023-12-03 06:17:14 25 4
gpt4 key购买 nike

是否可以在WPF控件资源中设置整数值?!

<UserControl.Resources>

<SolidColorBrush x:Key="MyLineBrush" Color="LightGreen" />

??? <Integer x:Key="MyStrokeThickness" Value="2" /> ???


<Style TargetType="local:MyLine" x:Key="MyLineStyleKey">

<Setter Property="Stroke"
Value="{DynamicResource MyLineBrush}"/>

<Setter Property="StrokeThickness"
Value="{DynamicResource MyStrokeThickness}"/>

</Style>

为了动态修改 MyLineBrushMyStrokeThickness 值...

最佳答案

要进行该声明,您需要导入 System 命名空间:

xmlns:sys="clr-namespace:System;assembly=mscorlib"

...

<sys:Int32 x:Key="MyValue">1234</sys:Int32>

注意:对于大多数 WPF 属性,您需要使用 Double 而不是 Int32

关于wpf - WPF 资源中的整数值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4185732/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com