Grid lines stlye in data grid ?
Last post 05-09-2008 8:18 AM by Jim Mangaly. 3 replies.
Sort Posts:
05-07-2008 8:30 AM
Grid lines stlye in data grid ?

I am trying to design a simple table with borders like an html table with border set. How do I do this in SL ? If I set ShowGridLines to true some ugly lines are drawn and also the border around the grid is missing. Is there a simple way to do this ?

Joe Robe

joer00

Joined on 07-05-2006
Posts 68
05-09-2008 12:14 AM
Re: Grid lines stlye in data grid ?

Hello, do you mean you want to design a Grid or a DataGrid? Since you mentioned ShowGridLines, I assume it's a Grid. You can put a Rectangle with no Fill in each cell. Don't worry, you can still add other elements into the cell. Each cell can host arbitrary elements. Try something like this:

<Border Height="480" Width="640" CornerRadius="10,10,10,10" BorderBrush="#FFFF0000" BorderThickness="2,2,2,2">

<Grid x:Name="LayoutRoot" Height="480" Width="640" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.498*"/>
<ColumnDefinition Width="0.502*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.498*"/>
<RowDefinition Height="0.502*"/>
</Grid.RowDefinitions>
<Rectangle HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Stroke="#FF008BFF"/>
<Rectangle HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Stroke="#FF008BFF" Grid.Column="1"/>
<Rectangle HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Stroke="#FF008BFF" Grid.Row="1"/>
<Rectangle HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Stroke="#FF008BFF" Grid.Row="1" Grid.Column="1"/>
<Button HorizontalAlignment="Stretch" Margin="38,70,65.7200012207031,88.0400009155273" VerticalAlignment="Stretch" Content="Other Contents for this cell"/>
<Button HorizontalAlignment="Stretch" Margin="38,70,65.7200012207031,88.0400009155273" VerticalAlignment="Stretch" Content="Other Contents for this cell" Grid.Row="1"/>
<Button HorizontalAlignment="Stretch" Margin="38,70,65.7200012207031,88.0400009155273" VerticalAlignment="Stretch" Content="Other Contents for this cell" Grid.Column="1"/>
<Button HorizontalAlignment="Stretch" Margin="38,70,65.7200012207031,88.0400009155273" VerticalAlignment="Stretch" Content="Other Contents for this cell" Grid.Row="1" Grid.Column="1"/>
</Grid>
</Border>

 

shanaolanxing - Please mark the posts as answers if they help and unmark if they don't.

Yi-Lun Luo - MSFT

Joined on 10-29-2007
Posts 1,037
05-09-2008 8:12 AM
Re: Grid lines stlye in data grid ?

yes sorry my post was a littel confusing because I mentioned data grid instead of gird, I meant a standard grid.

Thanks for your example, so there is indeed no EASY way to do this, meaning changing the style of the build in GridLines ?


Joe Robe

joer00

Joined on 07-05-2006
Posts 68
05-09-2008 8:18 AM
Re: Grid lines stlye in data grid ?

No, GridLines are really meant only as a guide to the developer when developing an application with the Grid.You would usually turn it off when going live.

There is no way to change the GridLine style. Since the Grid is a Panel and does not derive from the Control class, you cannot template it either.

Hope this helps,
Jim (http://jimmangaly.blogspot.com/)

Please MARK the replies as answers if they answered your question

Jim Mangaly

Joined on 04-21-2008
Kochi, India
Posts 68