GridView SelectedItem

3 posts, 0 answers
  1. Brian
    Brian avatar
    2 posts
    Member since:
    Dec 2011

    Posted 17 Jan 2012 Link to this post


    I have a RadGridView control bound to a CollectionViewSource.View.  I also have the SelectedItem bound to a VM Property with Mode=TwoWay.  I have a RadDataForm bound to the same collection as the RadGridView.  When the Grid first comes up, everything is fine.  When I select an item, things are fine.  The selected item in the grid appears in read-only mode in the RadDataForm.  When I click on the edit icon, change the value of a field, then click the Commit button the selected item moves to the row before the one I am editing but the highlighted row is the one I want to edit.  Also in my command method, the selected item is not what I edited.

    Properties of the RadGridView:
    <telerik:RadGridView Name="significantActivities" 
                                     ItemsSource="{Binding SignificantActivityCollection.View}" 
                                     SelectedItem="{Binding SelectedSignificantActivity, Mode=TwoWay}">

    Here is the code for SelectedSignificantActivity Dependency Property
    public Model.SignificantActivity SelectedSignificantActivity
                    return _selectedSignificantActivity; ;
                    if (_selectedSignificantActivity != value)
                        _selectedSignificantActivity = value;
                        // Update bindings no broadcast
    Here is the code in the Command method:
    DataService.SaveActivity(result => DispatcherHelper.CheckBeginInvokeOnUI(() =>
                                                 if (result)

    And here is the properites for the RadDataForm:
    <telerik:RadDataForm x:Name="dataForm"
                                     ItemsSource="{Binding SignificantActivityCollection.View}"
                                     ReadOnlyTemplate="{StaticResource significantActivityReadOnlyTemplate}"
                                     EditTemplate="{StaticResource significantActivityEditTemplate}"
                                     NewItemTemplate="{StaticResource significantActivityEditTemplate}" 
                        <i:EventTrigger EventName="EditEnded">
                            <mvvmLtCommanding:EventToCommand Command="{Binding EditSignificantActivityCommand}" />

    Any idea why my SelectedSignificantActivity is not set to the item I am actually editing?
  2. Brian
    Brian avatar
    2 posts
    Member since:
    Dec 2011

    Posted 17 Jan 2012 Link to this post

    Ok, I was able to apply what I would call "A HACK!".  I created an EventTrigger on the BeginningEdit event.  In my VM, I created a private field to hold the selected value when the code enters the BeginningEdit event.  Then when I am finished editing, I send the value of the field to the database.  This works.  The one thing I noticed is the object that is being edited goes to the bottom of the grid when the editing is completed.  But the highlighted field in the grid is still at the original position (wrong item and setting the selected item to the wrong item as well).
    This fixes the editing item, but breaks the adding of an item.
  3. Nedyalko Nikolov
    Nedyalko Nikolov avatar
    871 posts

    Posted 20 Jan 2012 Link to this post


    I've tried to simulate your problem unfortunately to no avail. Could you please send me a sample application which I can debug on my side in order to see what is going on?
    Thank you in advance.

    P.S. You need to open a support ticket in order to be able to attach files.

    Nedyalko Nikolov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top