Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6879473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:51:04+00:00 2026-05-27T04:51:04+00:00

I’m trying to obtain a table with the following format: Header 1 | Header

  • 0

I’m trying to obtain a table with the following format:

Header 1    |  Header 2

Col1 | Col2 | Col3 Col4

while using Silverlight.
I have searched, without success.

Any ideas?

[EDIT]

I have found this blog post, but the data and the column header doesn’t get align.
Merging Silverlight DataGrid Headers

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:51:05+00:00Added an answer on May 27, 2026 at 4:51 am

    I had some luck with the block entry mentioned at the edited question. Indeed header and data cells aren’t aligned. You need to manually adjust the sizes of these to match. In cases, where the data fields are expected to be of a common specified width, this will work fine. For reference, I am copying this solution here:

    <Style x:Key="DataGridBaseHeaderStyle" TargetType="dataprimitives:DataGridColumnHeader">
        <Setter Property="FontWeight" Value="Bold" />
    </Style>
    
    <Style x:Key="TimeSheetTotalsHeaderStyle" TargetType="dataprimitives:DataGridColumnHeader"
           BasedOn="{StaticResource TimeSheetDayHeaderStyle}">
        <Setter Property="Foreground" Value="#FFFF0000"/>
    </Style>
    
    <Style x:Key="TimeSheetDayHeaderStyle" TargetType="dataprimitives:DataGridColumnHeader" 
           BasedOn="{StaticResource DataGridBaseHeaderStyle}">
        <Setter Property="Foreground" Value="#FF000000"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="SeparatorBrush" Value="#FFC9CACA"/>
        <Setter Property="Padding" Value="8"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <Grid x:Name="Root">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ColorAnimation Duration="0" 
                                                        Storyboard.TargetName="BackgroundRectangle" 
                                                        Storyboard.TargetProperty="(Fill).Color" To="#FF448DCA"/>
                                        <ColorAnimation Duration="0" 
                                                        Storyboard.TargetName="BackgroundGradient" 
                                                        Storyboard.TargetProperty="(Fill).(GradientStops)[3].Color" To="#7FFFFFFF"/>
                                        <ColorAnimation Duration="0" 
                                                        Storyboard.TargetName="BackgroundGradient" 
                                                        Storyboard.TargetProperty="(Fill).(GradientStops)[2].Color" To="#CCFFFFFF"/>
                                        <ColorAnimation Duration="0" 
                                                        Storyboard.TargetName="BackgroundGradient" 
                                                        Storyboard.TargetProperty="(Fill).(GradientStops)[1].Color" To="#F2FFFFFF"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <ColorAnimation Duration="0" 
                                                        Storyboard.TargetName="BackgroundRectangle" 
                                                        Storyboard.TargetProperty="(Fill).Color" To="#FF448DCA"/>
                                        <ColorAnimation Duration="0" 
                                                        Storyboard.TargetName="BackgroundGradient" 
                                                        Storyboard.TargetProperty="(Fill).(GradientStops)[0].Color" To="#D8FFFFFF"/>
                                        <ColorAnimation Duration="0" 
                                                        Storyboard.TargetName="BackgroundGradient" 
                                                        Storyboard.TargetProperty="(Fill).(GradientStops)[1].Color" To="#C6FFFFFF"/>
                                        <ColorAnimation Duration="0" 
                                                        Storyboard.TargetName="BackgroundGradient" 
                                                        Storyboard.TargetProperty="(Fill).(GradientStops)[2].Color" To="#8CFFFFFF"/>
                                        <ColorAnimation Duration="0" 
                                                        Storyboard.TargetName="BackgroundGradient" 
                                                        Storyboard.TargetProperty="(Fill).(GradientStops)[3].Color" To="#3FFFFFFF"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SortStates">
                                <VisualState x:Name="Unsorted"/>
                                <VisualState x:Name="SortAscending" />
                                <VisualState x:Name="SortDescending" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Rectangle x:Name="BackgroundRectangle" Fill="#FF1F3B53" Stretch="Fill" Grid.ColumnSpan="2"/>
                        <Rectangle x:Name="BackgroundGradient" Stretch="Fill" Grid.ColumnSpan="2">
                            <Rectangle.Fill>
                                <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0">
                                    <GradientStop Color="#FCFFFFFF" Offset="0.015"/>
                                    <GradientStop Color="#F7FFFFFF" Offset="0.375"/>
                                    <GradientStop Color="#E5FFFFFF" Offset="0.6"/>
                                    <GradientStop Color="#D1FFFFFF" Offset="1"/>
                                </LinearGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                        <Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="20" />
                                <RowDefinition Height="1" />
                                <RowDefinition Height="20" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="50"/>
                                <ColumnDefinition Width="1" /> 
                                <ColumnDefinition Width="50"/>
                            </Grid.ColumnDefinitions>
                            <!-- Row 0 -->
                            <!-- This was edited in order to work in Silvelight 4 -->
                            <ContentPresenter Content="Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}" 
                                              VerticalAlignment="Center" HorizontalAlignment="Center" 
                                              Grid.ColumnSpan="3" />
    
                            <!-- Row 1 -->
                            <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch" Height="1" 
                                       Visibility="Visible" Grid.Row="1" Grid.ColumnSpan="3" />
                            <!-- Row 2 -->
                            <ContentPresenter Content="Qty" Grid.Row="2" VerticalAlignment="Center" 
                                              HorizontalAlignment="Center" />
                            <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch" Width="1"  
                                       Visibility="Visible" Grid.Row="2" Grid.Column="1" />
                            <ContentPresenter Content="Hours" Grid.Row="2" Grid.Column="2" 
                                              VerticalAlignment="Center" HorizontalAlignment="Center" />
                        </Grid>
                        <Rectangle x:Name="VerticalSeparator" Fill="#FFC9CACA" 
                                   VerticalAlignment="Stretch" Width="1" Visibility="Visible" 
                                   Grid.Row="1" Grid.Column="1"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    

    The original Style was slightly edited in order to work with Silverlight 4 (more details here).

    You also need to define a TextBox style with a fixed width that matches the width of the header:

    <Style x:Key="TimeSheetTextBoxStyle" TargetType="TextBox">
        <Setter Property="Width" Value="50"></Setter>
        <Setter Property="Background" Value="Transparent"></Setter>
        <Setter Property="BorderThickness" Value="0"></Setter>
    </Style>
    

    Use of the styles in the DataGrid:

    <data:DataGridTemplateColumn Header="Tue" HeaderStyle="{StaticResource TimeSheetDayHeaderStyle}">
        <data:DataGridTemplateColumn.CellTemplate>
            <DataTemplate>
                <StackPanel Orientation="Horizontal">
                    <TextBox Text="{Binding TuesdayQuantity}" Style="{StaticResource TimeSheetTextBoxStyle}"/>
                    <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch" Width="1" />
                    <TextBox Text="{Binding TuesdayHours}" Margin="2,0,0,0" Style="{StaticResource TimeSheetTextBoxStyle}"/>
                </StackPanel>
            </DataTemplate>
        </data:DataGridTemplateColumn.CellTemplate>
    </data:DataGridTemplateColumn>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.