[英]WPF define a staticresource from x:static for doubles
I want to define some resources in my App.Xaml for fontsize. 我想在App.Xaml中为fontsize定义一些资源。
This type of thing will work: 这种事情会起作用:
<sys:Double x:Key="FontLarge">24</sys:Double>
But I want to get the value from a :xStatic so something like this: 但是我想从:xStatic获取值,所以像这样:
<sys:Double x:Key="FontLarge">{x:Static local:Settings.FontLarge</sys:Double>
or 要么
<sys:Double x:Key="FontLarge" Value="{x:Static local:Settings.FontLarge"></sys:Double>
Neither of these work though. 这些都不起作用。 Is this possible and what would be the syntax? 这可能吗,语法是什么?
I don't think that there is a way to bind Double
value using x:Static
(I may be wrong though). 我不认为有一种方法可以使用x:Static
绑定Double
值(不过我可能错了)。
But there is always a way using code behind which you can use. 但是总有一种使用代码的方式可以使用。 If this is meant to be in App.Xaml, you can write 如果这打算放在App.Xaml中,则可以编写
App.Current.Resources.Add("FontLarge", Settings.FontLarge);
If some other class, you can just drop the App.Current
and that would work. 如果有其他类,则只需删除App.Current
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.