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

Get/Set grid's SelectedItems in MVVM

1 Answer 79 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 31 Mar 2014, 04:00 PM
Hi,

I my application is being written in a general MVVM architecture.  I'm wondering if there is any sort of way to be able to get rows to be "selected" without them actually being selected by the user.  For example I have something working using a style which binds to a property of my model and that works when the rows are manually selected via mouse clicks, however I cannot figure how to get rows to look visually selected when data is initially loaded.  Here is the Xaml I'm using to bind to the "IsSelected" property of collection of objects which are bound to my grid.

<UserControl.Resources>
     <Style TargetType="telerik:GridViewRow" BasedOn="{StaticResource {x:Type telerik:GridViewRow}}">
         <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
     </Style>
    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
</UserControl.Resources>

Any help on how to approach doing this would be greatly appreciated.

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 01 Apr 2014, 07:13 AM
Hi,

You can check this github example on how to bind the SelectedItems to a collection from your view model. 
Although GitHub is a very well-known platform we saw a better and easier approach for reviewing our examples developing our brand new SDK Samples Browser. You can also use it to review the examples.

Regards,
Didie
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
Tags
GridView
Asked by
David
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or