Current filter:
                                You should refresh the page.
                                Support Center

                                This example demonstrates how to bind GridControl's selected rows to a property in ViewModel in a MVVM-based application. The SelectionAttachedBehavior helper class used in this sample, provides a bindable SelectedItemsSource property, that can be used to define selection at the ViewModel level.

                                Note, we made the SelectionAttachedBehavior class as generic as possible, and the same approach can also be used for other controls that support multiple selection. This example demonstrates how this can be done when working with the standard ListBox control, as well as with the standard DataGrid.

                                • S Sharma 12.18.2012


                                  I am using this procedure to preserve selected rows for the WPF GridControl, but as we are updating the grid with new data in a timer, the selected rows are still getting lost. Please suggest how should we modify this sample so as to preserve grid selected rows even between the updates (like same selected rows should be present after the grid is updated with new data in a separate thread). Also, We are using a NavigationStyle=Cell, so just wanted to also check if we need to change the NavigationStyle to Row for your below sample to work with grid updates?


                                • Vidhyadhar Dhumal 03.25.2014

                                  In this example how to avoid multiple selection of rows. Our requirement is user should not be able to select mutiple rows. only single row should be allowed ro select. Hope this clarifies our requirement.

                                • Hello Vidhyadhar Dhumal,

                                  We accidentally discovered that your initial post was outside the scope of our Support Center. Please accept our sincere apologies for not responding in a timely manner.
                                  If this task is still important for you, find a couple of minutes to refer to the Q581629 thread. To implement the required selection mode, use the SelectionMode property as described in the Multiple Row Selection topic. To learn more about selection capabilities of the GridControl, refer to Selection.

                                  The issue with losing the selection during updating the grid was discussed in Q452866, you can find all information there.

                                Show Implementation Details
                                Select file
                                • MainWindow.xaml
                                • MainWindow.xaml.cs
                                • ViewModel.cs
                                Select language
                                • C#
                                • VB.NET
                                Select version
                                • 13.1.4 - 17.1.7

                                If you need additional product information, write to us at or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2017 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners