WPF DataGrid绑定一个组合列

WPF DataGrid绑定一个组合列

前台:

<Page.Resources>
        <local:InfoConverter x:Key="converter"></local:InfoConverter>
    </Page.Resources>

 

<DataGridTextColumn>
                        <DataGridTextColumn.Binding>
                            <MultiBinding Converter="{StaticResource converter}">
                                <Binding Path="Volume"></Binding>
                                <Binding Path="Unit"></Binding>
                            </MultiBinding>
                        </DataGridTextColumn.Binding>
</DataGridTextColumn>

后台:

public class InfoConverter : IMultiValueConverter 
    {

        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string volume = values[0].ToString();
            string unit = values[1].ToString();
            return volume + unit ;
        }

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

posted @ 2015-04-20 09:51  玖彩技术团队  阅读(455)  评论(0编辑  收藏  举报
以上只是个人想法和实践经验,如果有文字错误和语法错误,请加以指点! QQ:247039968 emil:wujc@younger.com 无论是美女的歌声,还是鬣狗的狂吠,无论是鳄鱼的眼泪,还是恶狼的嚎叫,都不会使我动摇