简体   繁体   English

人们在Windows 8中使用什么而不是IMultiValueConverters?

[英]What are people using instead of IMultiValueConverters in Windows 8?

I'm porting an existing WPF application to a Windows 8 application. 我正在将现有的WPF应用程序移植到Windows 8应用程序。

In the WPF application we make considerable use of MultiValue convertors to allow us to create values that are combinations of UI element properties and viewmodel properties (the weight of a hippo object and the actualWidth of an itemscontrol) to achieve nice UI effects. 在WPF应用程序中,我们大量使用MultiValue转换器,以允许我们创建值,这些值是UI元素属性和viewmodel属性(hippo对象的权重和itemscontrol的actualWidth)的组合,以实现良好的UI效果。

Windows 8, however, doesn't have a MultiValue convertor. 但是,Windows 8没有MultiValue转换器。

Since I'm porting an application I don't really want to significantly change my viewmodels or Xaml. 由于我正在移植一个应用程序,我真的不想显着改变我的viewmodels或Xaml。

How can I replicate Multivalue controller functionality with a minimum amount of pain and rewriting? 如何以最小的痛苦和重写来复制多值控制器功能?

My approach was to expose a static singleton instance of the VM; 我的方法是公开VM的静态单例实例; for example: 例如:

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

            return _mvm;
        }
    }

Then simple pass the whole VM through: 然后简单地通过整个VM:

<Button Command="{Binding MyCommand}" CommandParameter="{Binding MVM}">Run Command</Button>        

It's not multibinding, but it does allow you to pass multiple parameters. 它不是多重绑定,但它允许您传递多个参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 两个具有相同代码但名称不同的IMultiValueConverters-仅一个有效 - Two IMultiValueConverters with identical code, but different names - only one works 如何在Windows Phone 7中设置与人应用程序相同的滚动longlistselector? - how to set scrolling longlistselector same as people application in windows phone 7? ContentTemplate在Windows Phone中使用C#而不是XAML - ContentTemplate using C# instead of XAML in Windows Phone 如何在Windows Phone 7中创建类似于People Hub中的列表框? - How to create a listbox similar to that in People Hub in Windows Phone 7? XAML控件使用“可见性”类型而不是普通“布尔”的实际原因是什么? - What is the actual reason why XAML controls are using 'Visibility' type instead of plain 'bool'? 将联系人从我的Windows Store应用程序发送到People App,以将其添加到Exchange帐户 - Send a contact from my Windows-Store-App to People App to add it to Exchange account 窗户颜色是什么颜色? - What color is this windows color? Windows 7 和 Windows 10 的 ListViewItem 有什么区别 - What are the differences in ListViewItem between Windows 7 and Windows 10 如何在Windows Phone 8.1的ToggleButton中显示图像图标而不是文本? - How to show image icon instead of text in ToggleButton in Windows Phone 8.1? 设置Windows Phone Store应用程序启动页面而不是MainPage - Set windows phone store application start up page instead of MainPage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM