I am just starting with SL and WPF. I am using the DataGrid control and I need to remove the mouseover effect (I actually will need to do more customizations than that). How do I do this. I think I need to do it with a control template but not sure how. I'm researching and reading right now. Any help would be appreciated.
R – Silverlight 2.0 DataGrid How to remove mouseover effect
silverlight-2.0
Related Topic
- R – Silverlight Control Template Color Property
- C# – How to include a custom row at the end of a DataGrid in Silverlight
- R – How to improve the much-to-be-desired Silverlight installation experience
- R – Silverlight 2.0 loading issue
- R – How to simulate paging in Silverlight 2.0
- C# – How to pin one control below another in Silverlight
Best Answer
The short answer is to use styles. The long answer is the following:
There are two style properties in the Silverlight 2.0 datagrid that should solve your problem. The first is CellStyle and the second is RowStyle. The CellStyle property is the one which will remove the light blue highlight around the currently selected cell. The RowStyle property is the one where you will be able to remove the light blue shade indicating the selected row. The CellStyle that I used is as follows:
If you will notice, I commented out the storyboard that changed the FocusVisual rectangle's opacity value. What this was doing was to set the FocusVisual rectangle to be shown on cell selection. (Please Note: You cannot remove the FocusVisual Element as the CellPresenter is expecting this element, and not finding the element will cause an error.)
The RowStyle I used is as follows:
As you can see, I commented out some more visual states. You will want to comment out the MouseOver VisualState storyboard, the Normal Selected storyboard, the MouseOver Selected storyboard, and the Unfocused Selected storyboard.
(Please Note: I did not remove these visual states, I only commented out what they used to do.)
This is my code in its entirety for reference: (XAML first, then VB)
XAML:
VB:
Hope this helps.
Thanks, Scott