DataBinding之 MultiBinding

MilkTea.Common

转换器:

namespace MilkTea.Common
{
  public class MultiBindingConverter:IMultiValueConverter
  {
    public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
      //return values;
      return values.ToArray();
    }

    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
    {
      throw new NotImplementedException();
    }
  }
}

xaml:

  xmlns:comm="clr-namespace:MilkTea.Common;assembly=MilkTea.Common"

<Window.Resources>

  <comm:MultiBindingConverter x:Key="MyConverter"></comm:MultiBindingConverter>

</Window.Resources>

 

<Button Content="确定" Height="32" HorizontalAlignment="Left" Margin="113,243.333,0,0" x:Name="button1" VerticalAlignment="Top" Width="98" IsDefault="True"    Command="{Binding SubmitSetTasteCommand}">
  <Button.CommandParameter>
    <MultiBinding Converter="{StaticResource MyConverter}">
      <Binding ElementName="datagrid"></Binding>
      <Binding ElementName="myTesteWnd"></Binding>
    </MultiBinding>
  </Button.CommandParameter>
</Button>

 

MainViewModel.cs:

public ICommand SubmitSetTasteCommand
{
get
  {
    return new DelegateCommand<object>(
    (obj) =>
    {
    var args = (object[])obj;
    var gridview = (Telerik.Windows.Controls.RadGridView)args[0];
    var win = (Window)args[1];
    var selects = gridview.SelectedItems;

    });

  }

}

posted @ 2014-05-13 16:46  巩乃斯大叔  阅读(239)  评论(0编辑  收藏  举报