I am trying to run a command from a GridViewColumn, and the RadGridView is bound to my ViewModel. The code below runs the command, but when I select a value from the ComboBox, it saves the row immediately without allowing me to make changes to other cells first. This behavior happens whether or not I have the command bound to the RADComboBox. If I take the command away, still happens.
XAML:
Code
When I take the ComboBox out of the CellEditTemplate and try to use the GridViewComboBox, I can't figure out how to get the binding to work, but it doesn't fire off the RowEditEnded just by selecting the drop down so that part work correctly with this code:
If this is unclear let me know, it's late and I may not be clear. Thanks for any help you can offer. I should note that the RowEditEnded acts like this on other drop downs in my application as well when set up in the CellEditTemplate. Converting to the to the GridViewComboBoxCOlumn resolves that but then the binding issue...
XAML:
<
telerik:RadGridView
x:Name
=
"GV1"
ItemsSource
=
"{Binding Path=Material}"
AutoGenerateColumns
=
"False"
IsReadOnly
=
"{Binding IsGridReadOnly}"
ShowGroupPanel
=
"False"
VerticalAlignment
=
"Top"
HorizontalAlignment
=
"Center"
RowDetailsVisibilityMode
=
"VisibleWhenSelected"
>
<
i:Interaction.Triggers
>
<
i:EventTrigger
EventName
=
"RowEditEnded"
>
<
cmd:EventToCommand
Command
=
"{Binding RowEditEndedCommand}"
PassEventArgsToCommand
=
"True"
/>
</
i:EventTrigger
>
<
i:EventTrigger
EventName
=
"CancelRowEdit"
>
<
cmd:EventToCommand
Command
=
"{Binding CancelEditCommand}"
/>
</
i:EventTrigger
>
</
i:Interaction.Triggers
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewColumn
Header
=
"Material Code"
>
<
telerik:GridViewColumn.CellEditTemplate
>
<
DataTemplate
>
<
telerik:RadComboBox
ItemsSource
=
"{Binding DataSource.AllMaterials, Source={StaticResource DCP}}"
DisplayMemberPath
=
"Code"
SelectedValuePath
=
"Code"
SelectedValue
=
"{Binding Path=MaterialCode, Mode=TwoWay}"
IsEnabled
=
"{Binding Path=IsMaterialEditable, Mode=TwoWay}"
Command
=
"{Binding DataSource.MaterialCodeChangedCommand, Source={StaticResource DCP}}"
/>
</
DataTemplate
>
</
telerik:GridViewColumn.CellEditTemplate
>
<
telerik:GridViewColumn.CellTemplate
>
<
DataTemplate
>
<
TextBlock
Text
=
"{Binding MaterialCode}"
/>
</
DataTemplate
>
</
telerik:GridViewColumn.CellTemplate
>
</
telerik:GridViewColumn
>
<!--7 Other Columns here-->
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
Code
public
RelayCommand MaterialCodeChangedCommand {
get
;
private
set
; }
//IN Constructor
this
.MaterialTypeChangedCommand =
new
RelayCommand(MaterialTypeChange);
private
void
MaterialCodeChange()
{
//Command code here
}
When I take the ComboBox out of the CellEditTemplate and try to use the GridViewComboBox, I can't figure out how to get the binding to work, but it doesn't fire off the RowEditEnded just by selecting the drop down so that part work correctly with this code:
<
telerik:GridViewComboBoxColumn
Header
=
"Material Type"
ItemsSource
=
"{Binding DataSource.AllTypeCodes, Source={StaticResource DCP}}"
SelectedValueMemberPath
=
"Code"
DataMemberBinding
=
"{Binding Path=MaterialType, Mode=TwoWay}"
DisplayMemberPath
=
"Display"
>
<
i:Interaction.Triggers
>
<
i:EventTrigger
EventName
=
"SelectionChanged"
>
<
i:InvokeCommandAction
Command
=
"{Binding DataSource.MaterialTypeChangedCommand, Source={StaticResource DCP}}"
/>
</
i:EventTrigger
>
</
i:Interaction.Triggers
>
</
telerik:GridViewComboBoxColumn
>
If this is unclear let me know, it's late and I may not be clear. Thanks for any help you can offer. I should note that the RowEditEnded acts like this on other drop downs in my application as well when set up in the CellEditTemplate. Converting to the to the GridViewComboBoxCOlumn resolves that but then the binding issue...