Hi All,
How to highlight the XamGrid row programmaticaly (through c# code) ?
Regards
Sufyan
Please keep in mind i am using MVVM. Please help me with sample application.
Hello Sufyan,
Thank you for your post. I have been looking into it and I created a sample project with the functionality you want. Basically I have a bool Property in the ViewModel called IsHighlighted and by using DataTrigger in the CellControl’s Style I set the Background of the Cells which Row’s object has this Property set to true. You can just edit the column in the Grid to see how the functionality works. You can also hide IsHighlighted Column from the Grid if you want. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Hello Stefan,
Thank you so much for your reply. Actually we use grouping on xamGrid and expand all groups, user select the any row from grid to modify. we done modification through another user control and make some business logic through user control and saved that logic in data base than we fetch all records from database and display in grid. At this state page is refreshed and we loose the selected row. How can select the row that was modified ? Modify sample is attached.
Hello,
I have modified the sample, so now the ActiveItem Property of the XamGrid is bound to a ViewModel’s Property called MyActiveItem, this way by setting this property to an item from the DataSource will activate the desired item in the XamGrid.
Hope this helps you.
Thank you for your reply. I check the modified sample when i click on a button my grid is clear, no records are displayed and i used a grid click event to get the selected item and saved in a temporary variable and on GroupByRowCellsPanel_Loaded i assigned that temporary variable to the property that are bound to Grid ActiveItem but still i am not able to highlight the selected record after grid refresh. Please see my attached sample and modify sample again that may be helpful for me.
Regards,
The GetData method that I used generates random objects every time it is called, so when you set the DataContext to it the objects are new and the MyActiveItem Property is set to its default value. The approach I gave you is just a guidance, which you can use as basis to achieve the functionality you want. Also you if you need to implement any custom scenarios, as the ability to rotate the 3D chart, you can contact our Consulting Team. You can read more detailed information regarding this here in our web site:
http://ko.infragistics.com/consulting/
I am looking your previous sample. First time when the page is loaded Grid display the records i select the row from grid to modify and press click button here not opened the other user control for modification assume through user control we modify that record and after modification we assign the collection again to grid, before the button clicked DataContext have the MyActiveItem property and Grid Data collection. When i press the button "this.DataContext = Data.GetData(10, 0, 10); " this will again assign the data to DataConext but grid not shown that records and after that i do not have MyActiveItem property, only Data collection is here but not display that records in grid. Please look into it, How can i assign the data again to grid and where i set the MyActiveItem property ?
I have modified the sample I sent you before, so now it works as you want.
Not understand exactly, it is possible to prepare a solution for me i really very appreciate for this favor.
I have been looking into your post and I can say that when you change the DataSource of the Grid you are able to save the ActiveItem as MyActiveItem Property, but when you set a new DataSource if it doesn’t contain MyActiveItem you are not able to set it as XamGrid’s ActiveItem. You are able to do so only if the datasource contains the very same instance. A possible solution is to set MyActiveItem to an item from the newly added collection based on the previously saved item.