This is a migrated thread and some comments may be shown as answers.

Select a row from ViewModel

5 Answers 122 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Roy Halvorsen
Top achievements
Rank 1
Roy Halvorsen asked on 30 Sep 2010, 07:30 AM
How do I select a spesific row from my ViewModel (we're using mvvm pattern and no codebehind)? I have tried several approaches with no luck. Tried to set SelectedItem, tried to set CurrentItem, IsSynchronizedWithCurrentItem true/false. Nothing seems to help. Debugging the ViewModel shows that the row is selected, but the Gui is not updated.

5 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 01 Oct 2010, 10:01 AM
Hi Roy Halvorsen,

I have attached a sample project which demonstrates how you can bind RadGridView's SelectedItem to a ViewModel and change the SelectedItem from the ViewModel itself.

Hope it helps.


Kind regards,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
ardmore
Top achievements
Rank 1
answered on 07 Jul 2016, 01:44 PM
Can we access the SelectedItem from ViewModel? The example used it from code behind.
0
Stefan
Telerik team
answered on 11 Jul 2016, 02:59 PM
Hi Hui,

In the attached demo application, indeed, the value of the SelectedItem property is changed on a button click in the code behind. Please, however, take a closer look, that the property is actually defined in the view model and the SelectedItem property of RadGridView is bound to it. You have a direct access to the SelectedItem property in the view model and can update it as per your requirements.

Best Regards,
Stefan X1
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
ardmore
Top achievements
Rank 1
answered on 11 Jul 2016, 06:16 PM

I meant  Click="Button1_Click" is in code behind.

I want to it in ViewModel to handle the property.

0
Stefan
Telerik team
answered on 14 Jul 2016, 02:09 PM
Hello Hui,

The way to go  is to use an ICommand. You may find the Basic MVVM and ICommand  Usage Example article useful on the matter.

Hope this helps.

Regards,
Stefan X1
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Roy Halvorsen
Top achievements
Rank 1
Answers by
Milan
Telerik team
ardmore
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or