I have an xamdatagrid within which there is column of type combobox, now I want to get the selectedrowindex of xamdatagrid if I am makin any change to selection of combobox.
I have used below style for adding combobox as fieldtype within xamdatagrid but I am not getting the value of commandparameter within the viewmodel, I am always getting value of Object O within ContinueSave(object o) as null
<Style x:Key="combo" TargetType="{x:Type idp:CellValuePresenter}"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <ComboBox ItemsSource="{Binding Path=DataContext.DataItem.Options,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type idp:CellValuePresenter}}}" DisplayMemberPath="Label" SelectedItem="{Binding Path=DataContext.DataItem.Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type idp:CellValuePresenter}}}"> <i:Interaction.Triggers> <i:EventTrigger EventName="SelectionChanged"> <i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.SelectionChangeCommand, Mode=OneWay}" CommandParameter="{Binding Path=DataContext.DataItem.CalcSequence}"/> </i:EventTrigger> </i:Interaction.Triggers> </ComboBox> </DataTemplate> </Setter.Value> </Setter> </Style>
Here is the code in viewmodel:
private DelegateCommand<object> selectionChangeCommand;
/// <summary> /// Handle grid header column mapping command /// </summary> public DelegateCommand<object> SelectionChangeCommand { get { if (selectionChangeCommand == null) selectionChangeCommand = new DelegateCommand<object>(param => this.ContinueSave(param), param => true); return selectionChangeCommand; } } private void ContinueSave(object o) { // Do something }
Hello Richa,
Thank you for contacting Infragistics Developer Support.
If the parameter is null and the object in the view model isn’t, then the binding must be failing. If that is the case, generally binding errors are shown in the VS Output. You can check if you have these errors as they provide valuable information as to what has gone wrong. If this information isn’t enough for you to figure out what has gone wrong, please create a small sample that demonstrates this issue and I will be glad to debug it for you.
I am looking forward to hearing from you.