在另一个双精度资源中引用双精度资源
我想在另一个 Double 资源中引用 Double 资源, 像这样的东西:
<
sys:Double x:Key="height">{ StaticResource width}
我该怎么做?
I would like to reference a resource of Double inside another Double resource,
something like this:
<sys:Double x:Key="width">100</sys:Double>
<sys:Double x:Key="height">{StaticResource width}</sys:Double>
How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我怀疑这是可能的,您正在引用一个原子数据类型,它只能包含一个既不是字段也不是属性的数值。为了实现这一点,您可能需要创建自己的数据类型。
编辑:通常您应该能够使用
DynamicResource
为此:(Visual Studio 不会喜欢这个,但它应该编译并工作)
I doubt that this is possible, you are referencing an atomic data-type that can contain nothing else than a numeric value which is neither a field nor a property. To allow that you probably need to create your own datatype.
Edit: Normally you should be able to use a
DynamicResource
for this:(Visual Studio won't like this but it should compile and work)
好吧,我不确定您给出的示例是否有效,因为我无法绑定到“sys:Double”。
但除此之外,你问题的答案:
您可以使用转换器,而且非常简单。
添加此类:
然后在 xaml 中引用此类(确保首先使用项目的 xmlns):
现在在绑定中您可以执行以下操作:
Well, i'm not sure the example you're giving could work, since i'm not able to do a binding to "sys:Double".
but other than that, the answer to you question:
you can use a convertor, and it's pretty simple.
add this class:
and than reference this class in the xaml (make sure to use the xmlns of your project first):
now in your binding you can do something like: