This question is locked. New answers and comments are not allowed.
Because I wanted to use multiple instances of the same control I decided to move the below implementation (which works) from xaml to codebehind. <telerik:GridViewDataColumn Header="Duration"DataMemberBinding="{Binding Converter={StaticResource DurationConverter}}" Width="85"/>
public class DurationConverter: IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return ((myEntity)value).DurationValue + " " + ((myEntity)value).durationType; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } }
This converter combines two fields to give me something like "3 Weeks" or "5 days"Now, in my codebehind, I have the following which works for "normal" GridViewDataColumns but not for columns that bind with a static converter. private void rgvEmpSubControl_Loaded(object sender, RoutedEventArgs e) { GridViewDataControl dataControl = (GridViewDataControl)sender; dataControl.Columns.Clear(); bnd = new Binding(); bnd.Mode = BindingMode.TwoWay; bnd.Path = new PropertyPath("SelectedItem"); bnd.Source = _viewModel.EmpTrainings; dataControl.Columns.Add(DataColummParameters("Duration", "abc", 85)); dataControl.SetBinding(GridViewDataControl.SelectedItemProperty, bnd); } private GridViewDataColumn DataColummParameters(string _Header, string _Binding, int intWidth) { GridViewDataColumn GVDC = new GridViewDataColumn(); GVDC.DataMemberBinding = new Binding(_Binding); GVDC.Header = _Header; GVDC.Width = intWidth; return GVDC; } My questions ishow can I structure "abc" to produce the codebehind equivalent of [DataMemberBinding="{Binding Converter={StaticResource DurationConverter}}" ] ?