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 3672556
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:37:25+00:00 2026-05-19T02:37:25+00:00

Hi i was looking to align my group headers horizontally.I had succeeded to do

  • 0

Hi i was looking to align my group headers horizontally.I had succeeded to do so but now the problem is that if i scroll horizontally my group headers are also scrolling.How to fix this.I want my group headers to be fixed and only my content to scroll

My code is given below.

Xaml

<Window.Resources>
    <local:Animals x:Key="animals"/>       

    <CollectionViewSource x:Key="cvs" Source="{Binding Source={StaticResource animals}, Path=AnimalList}">
        <CollectionViewSource.SortDescriptions>
            <scm:SortDescription PropertyName="Category" />
            <scm:SortDescription PropertyName="Name" />
        </CollectionViewSource.SortDescriptions>
        <CollectionViewSource.GroupDescriptions>
            <PropertyGroupDescription PropertyName="Category"/>
        </CollectionViewSource.GroupDescriptions>
    </CollectionViewSource>

    <DataTemplate x:Key="animalTemplate">
        <TextBlock Text="{Binding Path=Name}" Foreground="MediumSeaGreen"/>
    </DataTemplate>
    <Style TargetType="{x:Type HeaderedContentControl}">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type HeaderedContentControl}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <StackPanel Orientation="Horizontal">
                            <ContentPresenter
                            Content="{TemplateBinding HeaderedContentControl.Header}"
                            ContentTemplate="{TemplateBinding HeaderedContentControl.HeaderTemplate}"
                            ContentSource="Header" VerticalAlignment="Center">
                            </ContentPresenter>
                            <ContentPresenter                             
                            Content="{TemplateBinding ContentControl.Content}"
                            ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" />
                        </StackPanel>

                        <Separator HorizontalAlignment="Stretch" Grid.Row="1" Margin="-1"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</Window.Resources>

<Border Margin="30" BorderBrush="Blue" BorderThickness="2" Padding="10">
    <Controls:DataGrid ItemsSource="{Binding Source={StaticResource cvs}}" 
       ItemTemplate="{StaticResource animalTemplate}" Name="ic" Width="200" >

        <Controls:DataGrid.GroupStyle>
            <GroupStyle>
                <GroupStyle.ContainerStyle>
                    <Style TargetType="{x:Type GroupItem}">
                        <Setter Property="Margin" Value="0,0,0,5"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type GroupItem}">
                                    <HeaderedContentControl BorderBrush="#FFA4B97F" BorderThickness="0,0,0,1" Margin="0,0,0,5" >
                                        <HeaderedContentControl.Header>
                                            <TextBlock FontSize="12" FontWeight="Bold" Width="100"
                                                                Text="{Binding Name}" Margin="5,0,0,0"/>
                                        </HeaderedContentControl.Header>
                                        <HeaderedContentControl.Content>
                                            <ItemsPresenter/>
                                        </HeaderedContentControl.Content>
                                    </HeaderedContentControl>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </GroupStyle.ContainerStyle>
            </GroupStyle>
        </Controls:DataGrid.GroupStyle>
    </Controls:DataGrid>
</Border>

Code

  public class Animal
{
    private string name;

    public string Name
    {
        get { return name; }
        set { name = value; }
    }

    private Category category;

    public Category Category
    {
        get { return category; }
        set { category = value; }
    }

    public Animal(string name, Category category)
    {
        this.name = name;
        this.category = category;
    }
}

public enum Category
{
    Amphibians,
    Bears,
    BigCats,
    Canines,
    Primates,
    Spiders,
}

public class Animals
{
    private List<Animal> animalList;

    public IEnumerable<Animal> AnimalList
    {
        get { return animalList; }
    }

    public Animals()
    {
        animalList = new List<Animal>();
        animalList.Add(new Animal("California Newt", Category.Amphibians));
        animalList.Add(new Animal("Giant Panda", Category.Bears));
        animalList.Add(new Animal("Coyote", Category.Canines));
        animalList.Add(new Animal("Golden Silk Spider", Category.Spiders));
        animalList.Add(new Animal("Mandrill", Category.Primates));
        animalList.Add(new Animal("Black Bear", Category.Bears));
        animalList.Add(new Animal("Jaguar", Category.BigCats));
        animalList.Add(new Animal("Bornean Gibbon", Category.Primates));
        animalList.Add(new Animal("African Wildcat", Category.BigCats));
        animalList.Add(new Animal("Arctic Fox", Category.Canines));
        animalList.Add(new Animal("Tomato Frog", Category.Amphibians));
        animalList.Add(new Animal("Grizzly Bear", Category.Bears));
        animalList.Add(new Animal("Dingo", Category.Canines));
        animalList.Add(new Animal("Gorilla", Category.Primates));
        animalList.Add(new Animal("Green Tree Frog", Category.Amphibians));
        animalList.Add(new Animal("Bald Uakari", Category.Primates));
        animalList.Add(new Animal("Polar Bear", Category.Bears));
        animalList.Add(new Animal("Black Widow Spider", Category.Spiders));
        animalList.Add(new Animal("Bat-Eared Fox", Category.Canines));
        animalList.Add(new Animal("Cheetah", Category.BigCats));
        animalList.Add(new Animal("Cheetah", Category.Spiders));
    }
}

Please help in this regard..

  • 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-19T02:37:26+00:00Added an answer on May 19, 2026 at 2:37 am

    Put a ScrollViewer around your DataGrid.
    I also removed the Width from the DataGrid.

    <Border Margin="30" BorderBrush="Blue" BorderThickness="2" Padding="10">
     <ScrollViewer HorizontalScrollBarVisibility="Auto" 
                   VerticalScrollBarVisibility="Auto">
         <DataGrid ItemsSource="{Binding Source={StaticResource cvs}}"         
                   ItemTemplate="{StaticResource animalTemplate}" 
                   Name="ic" >
         </DataGrid>
       </ScrollViewer>
    </Border>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: I added text-align: right; to social-media , but now I'm looking like this:
I can horizontally align a div and all the content looks nice. Looking to
I'm attempting to create a nice looking droppable area for elements that align themselves
I'm looking for a solution to align some images vertically and horizontally in the
Looking for a control that allows to select one text value at a time
I'm looking to align one of my <div> containers which has a nested <form
Hi i am looking for a way to align the buttons in my treeview
I'd like to bottom-align cells in a tiled DataGroup, so that rows grow bottom-top
I'm looking for a very basic example that will change the TD font size
I am looking to position the box that is floating on the right of

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.