x:UWP XAML 中的静态 [英] x:Static in UWP XAML

查看:26
本文介绍了x:UWP XAML 中的静态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发的应用程序需要将 ConverterParameter 设为枚举.为此,通常的做法是:

An app I'm working on requires a ConverterParameter to be an enum. For this, the regular way to do would be:

{Binding whatever, 
    Converter={StaticResource converterName}, 
    ConverterParameter={x:Static namespace:Enum.Value}}

然而,UWP 平台 x: 命名空间似乎没有静态扩展.

However, the UWP platform x: namespace does not seem to have the Static extension.

有谁知道是否有不依赖 x:Static 来比较绑定中的枚举的解决方案?

Does anyone know if there's a solution that does not rely on x:Static for comparing an enum in binding?

推荐答案

这对我在 UWP 中有用:

This works for me in a UWP:

<Button Command="{Binding CheckWeatherCommand}">
  <Button.CommandParameter>
     <local:WeatherEnum>Cold</local:WeatherEnum>
  <Button.CommandParameter>
</Button>

这篇关于x:UWP XAML 中的静态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆