I have a xamgrid which has Group by functionality and it works correctly
However the xamgrid has comboeditor and that comboeditor displays the value and is tied to id
Though the grouping works correctly, In the group by it displays the id (i.e 1/2/3) and not the value that is bound to those ids
If it possible to show the actual value and not the id
For some reason I was having some value as null
Resolved it
Thank you so much for your help
I modified code and now I have
<converter:GroupByValueConverter x:Key="GroupByValueConverter" ViewModel="{Binding ElementName=LayoutRoot,Path=DataContext.view1s}"></converter:GroupByValueConverter>
<ig:TemplateColumn.GroupByItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Value, Converter={StaticResource GroupByValueConverter}}"></TextBlock> </StackPanel> </DataTemplate> </ig:TemplateColumn.GroupByItemTemplate> <ig:TemplateColumn.ItemTemplate>
GroupValueConverter code
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
var view = (EntitySet<view1>)ViewModel; return view.FirstOrDefault(row => row.ID== (int)value).Description; }
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); }
#endregion
#region object ViewModel (DependencyProperty) public object ViewModel { get { return (object)GetValue(ViewModelProperty); } set { SetValue(ViewModelProperty, value); } } public static readonly DependencyProperty ViewModelProperty = DependencyProperty.Register( "ViewModel", typeof(object), typeof(GroupByValueConverter),
new PropertyMetadata(null, null)); #endregion ViewModel (DependencyProperty)
Now it does not recognise the value
Any pointers what is missing?
Hi,
1. So, in the link you posted, you'll note that the DataContext is a type called GroupByDataContext:
http://help.infragistics.com/Help/NetAdvantage/Silverlight/2009.1/CLR3.5/html/Infragistics.Silverlight.v9.1~Infragistics.Silverlight.GroupByDataContext_members.html
Thus you can't bind to "field1" as its not a valid binding.
2. ConverterParameter doesn't support Bindings...and if it did, DataTemplates in the xamGrid can't support ElementName bindings. So you'll have to use a StaticResource to get to your ViewModel.
-SteveZ
Link for the earlier reply is http://help.infragistics.com/Help/NetAdvantage/Silverlight/2009.1/CLR3.5/html/SL_xamWebGrid_Custom_Groupby_Row_Display.html
I am using this sample as a reference
Having the field as
<ig:TemplateColumn.GroupByItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding field1, Converter={StaticResource GroupByValueConverter},ConverterParameter={Binding ElementName=LayoutRoot, Path=DataContext.view1}}"></TextBlock> </StackPanel> </DataTemplate>
</ig:TemplateColumn.GroupByItemTemplate>
But for some reason it give error saying value isnt passed