xaml - 人们在 Windows 8 中使用什么来代替 IMultiValueConverters?

标签 xaml mvvm windows-8

我正在将现有的 WPF 应用程序移植到 Windows 8 应用程序。

在 WPF 应用程序中,我们大量使用 MultiValue 转换器来允许我们创建由 UI 元素属性和 View 模型属性(河马对象的权重和项目控件的实际宽度)组合而成的值,以实现良好的 UI 效果。

但是,Windows 8 没有 MultiValue 转换器。

由于我正在移植一个应用程序,我真的不想显着改变我的 View 模型或 Xaml。

如何以最少的痛苦和重写来复制多值 Controller 功能?

最佳答案

我的方法是公开 VM 的静态单例实例;例如:

public class MainViewModel : INotifyPropertyChanged
{
    private static MainViewModel _mvm;
    public static MainViewModel MVM
    {
        get
        {
            if (_mvm == null)
                _mvm = new MainViewModel();

            return _mvm;
        }
    }

然后简单地通过整个VM:
<Button Command="{Binding MyCommand}" CommandParameter="{Binding MVM}">Run Command</Button>        

它不是多重绑定(bind),但它确实允许您传递多个参数。

关于xaml - 人们在 Windows 8 中使用什么来代替 IMultiValueConverters?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17461747/

相关文章:

c# - 当 TextBox 子项失去焦点时,ScrollViewer 跳到顶部

c# - 如何更改列标题文本大小

c# - Xamarin 形成细胞操作 RTL

wpf - 如何在WPF MVVM中调用窗口的Loaded事件?

wpf - wpf中的复选框禁用和启用

mvvm - syncfusion 图表不显示数据

android - 在 Android MVVM 架构中显示来自 ViewModel 的对话框

powershell - 来自 Powershell 的 MessageDialog

javascript - 溢出 div 上的 "Scroll down to update"(或左侧)特征

windows-8 - Windows Notification Server 上的附加参数