How to pass Multiple parameters as CommandParameter in InvokeCommandAction In WPF App Using MVVM

前端 未结 2 2062
别跟我提以往
别跟我提以往 2020-12-10 21:58

I am using System.Windows.interactivity.dll to get mouse events in my ViewModel in the following manner.

 

        
2条回答
  •  眼角桃花
    2020-12-10 22:35

    You can try with custom Converter and MultiBinding

    
          
           
           
          
    
    

    Converter

    class CustomConverter : IMultiValueConverter 
    {
        public object Convert (object[] Values, Type Target_Type, object Parameter, CultureInfo culture) 
        {
            var findCommandParameters = new FindCommandParameters();
            findCommandParameters.Property1 = (string)values[0];
            findCommandParameters.Property1 = (string)values[1];
            return findCommandParameters;
        }
        public object[] ConvertBack(object value, Type[] targetTypes, object parameter,   System.Globalization.CultureInfo culture)
        {
           throw new NotImplementedException();
        }
    }
    

    Parameters

    public class FindCommandParameters
    {
      public string Property1 { get; set; }
      public string Property2 { get; set; }
    }
    

提交回复
热议问题