[英]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.