自定义在XamDataGrid中排序以进行多重绑定

时间:2015-02-12 15:06:30

标签: c# wpf infragistics xamdatagrid

我有一个很棒的multiBinding, 我希望能够对某个列进行排序,它显示w:width,h:height
据我所知,我需要构建一个自定义IComparer类来进行比较。
这是我的XAML

<igWPF:UnboundField Label="Output&#10;Width/Height" Width="auto">
  <igWPF:Field.Settings>
    <igWPF:FieldSettings SortComparer="{StaticResource SortWidthHeightComparer }">
      <igWPF:FieldSettings.CellValuePresenterStyle>
        <Style TargetType="{x:Type igWPF:CellValuePresenter}">
         <Setter Property="Template">
          <Setter.Value>
           <ControlTemplate TargetType="{x:Type igWPF:CellValuePresenter}" >
            <TextBlock Margin="3">
             <TextBlock.Text>
              <MultiBinding Converter="{StaticResource settingsBdsToStringConverter}">
               <Binding Path="DataItem.Key"/>
               <Binding Path="DataContext.SelectedPipeMode" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type igWPF:XamDataGrid}}"/>
              </MultiBinding>
             </TextBlock.Text>
            </TextBlock>
           </ControlTemplate>
          </Setter.Value>
         </Setter>
        </Style>
       </igWPF:FieldSettings.CellValuePresenterStyle>
      </igWPF:FieldSettings>
     </igWPF:Field.Settings>
   </igWPF:UnboundField>

这是我的多重绑定转换器

class SettingsOutputResToStringConverter : IMultiValueConverter
    {

        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values[1] is Mode && values[0] is ConfigurationKey)
            {
                var pMode = (Mode)values[1];
                var key = values[0] as ConfigurationKey;
                var res = key.GetOutput(pMode);
                return String.Format("W: {0}, H: {1}", res.Width, res.Height);
            }
            return String.Empty;
        }
        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            return null;
        }
    }

但是我的问题是如何将multibind结果传递给Comparer类

class SortWidthHeightComparer : IComparer
    {
        public int Compare(object x, object y)
        {
            return 1;
        }
    }

object xobject y始终为空

1 个答案:

答案 0 :(得分:1)

吉拉德, 我发现这篇文章: http://www.infragistics.com/community/forums/t/17878.aspx

这似乎是一个简单的解决方案。 我将尝试使用相同的方法来过滤记录。