Page view counter
Styling a DataGrid selected row
Last post 10-13-2008 5:20 AM by Tregarick. 2 replies.
Sort Posts:
10-07-2008 8:48 AM
Styling a DataGrid selected row

I have a design requirement where all the rows of my datagrid are different colours to represent different status's of a row.  I have been able to do this by using TemplateColumns containing StackPanels that have their background properties bound to a Status property of the rows DataItem using a ValueConverter.  The problem I have is that you now cant tell if a row is selected or being hovered over so I wanted to put a thick black border around any rows that have been selected.  The problem is I have no idea how to do this and was wondering if anyone could give me some pointers or ideas assuming its even possible.

Tregarick

Loading...
Joined on 09-19-2008
Posts 19
10-13-2008 4:35 AM
Marked as Answer
Re: Styling a DataGrid selected row

Hi Tregarick,

Actually, MouseOver Selected state is already defined by default. To modify its behavior,  we recommend you use Blend.   For example,

          <Rectangle x:Name="BackgroundRectangle" Opacity="0" Grid.ColumnSpan="2" Grid.RowSpan="2" Fill="#FFBADDE9"/>    //background.
          <System_Windows_Controls_Primitives:DataGridRowHeader x:Name="RowHeader" Grid.RowSpan="3" System_Windows_Controls_Primitives:DataGridFrozenGrid.IsFrozen="True"/>
          <System_Windows_Controls_Primitives:DataGridCellsPresenter x:Name="CellsPresenter" Grid.Column="1" System_Windows_Controls_Primitives:DataGridFrozenGrid.IsFrozen="True"/>
          <System_Windows_Controls_Primitives:DataGridDetailsPresenter x:Name="DetailsPresenter" Grid.Column="1" Grid.Row="1"/>
          <Rectangle Height="1" HorizontalAlignment="Stretch" x:Name="BottomGridLine" Grid.Column="1" Grid.Row="2"/>
         

How to use Blend, you'd better take a look at the videos here.

Best regards,

Jonathan

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

Jonathan Shen – MSFT

Loading...
Joined on 06-18-2007
Posts 440
10-13-2008 5:20 AM
Re: Styling a DataGrid selected row
Thanks Jonathan will take a look.
Tregarick

Loading...
Joined on 09-19-2008
Posts 19
Microsoft Communities