How to create a border table in Silverlight?

I am currently using Silverlight 3. I want to create the equivalent of a 2x2 HTML table. I want each cell to have a black border. How to do it in Silverlight? Isn't there a property that I can set in the element Gridso that each cell has a border?

+3
source share
1 answer

Nope. A grid is just one of several types of panels that are designed to place their children in detail. Nets are widely used in many different and often nested ways. They are lightweight and, therefore, do not carry loads of luggage that may or may not be used, for example, in this set of properties to define boundaries on “cells”.

To create a border for each cell, just use the control Border:

<Grid>
  <Grid.Resources>
    <Style x:Key="borderStyle" TargetType="Border">
      <Setter Property="BorderBrush" Value="Black" />
      <Setter Property="BorderThickness" Value="1" />
      <Setter Property="Padding" Value="2" />
    </Style>
  </Grid.Resources>
  <Grid.RowDefinitions>
    <RowDefinition Height="*" />
    <RowDefinition Height="*" />
  </Grid.RowDefinitions>
  <Grid.ColumnDefinitions>
    <ColumnDefinition Width="*" />
    <ColumnDefinition Width="*" />
  </Grid.ColumnDefinitions>
  <Border Style="{StaticResource borderStyle}" Grid.Row="0" Grid.Column="0">
    <!-- Cell 0.0 content here -->
  </Border>
  <Border Style="{StaticResource borderStyle}" Grid.Row="0" Grid.Column="1">
    <!-- Cell 0.1 content here -->
  </Border>
  <Border Style="{StaticResource borderStyle}" Grid.Row="1" Grid.Column="0">
    <!-- Cell 1.0 content here -->
  </Border>
  <Border Style="{StaticResource borderStyle}" Grid.Row="1" Grid.Column="1">
    <!-- Cell 1.1 content here -->
  </Border>
</Grid>
+4
source

Source: https://habr.com/ru/post/1744618/


All Articles