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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:15:44+00:00 2026-05-22T16:15:44+00:00

Datagrid xaml code: <controls:DataGrid Name=dataGrid AutoGenerateColumns=False > <controls:DataGrid.GroupStyle> <GroupStyle> <GroupStyle.HeaderTemplate> <DataTemplate> <StackPanel> <TextBlock Text={Binding

  • 0

Datagrid xaml code:

  <controls:DataGrid Name="dataGrid" AutoGenerateColumns="False" >
    <controls:DataGrid.GroupStyle>
        <GroupStyle>
            <GroupStyle.HeaderTemplate>
                <DataTemplate>
                    <StackPanel>
                        <TextBlock Text="{Binding Path=Name}" />
                     </StackPanel>
                </DataTemplate>
            </GroupStyle.HeaderTemplate>
        </GroupStyle>
    </controls:DataGrid.GroupStyle>

        <controls:DataGrid.Columns>
            <controls:DataGridTextColumn Header="Student ID"  Width="90*" MinWidth="120" Binding="{Binding StudentId}"/>
            <controls:DataGridTextColumn Header="Student Name" Width="90*" MinWidth="120" Binding="{Binding Name}"/>
            <controls:DataGridTextColumn Header="Score" Width="100*" MinWidth="150" Binding="{Binding Score}"/>
        </controls:DataGrid.Columns>
    </controls:DataGrid>

Here the code behind:

    void LoadDatagrid()
    {
        List<Student> _studentList = new List<Student>();

        _studentList.Add(new Student()
        {
            StudentId = 1,
            Name = "Paul Henriot",
            Department = "IT",
            Score = 540
        });

        _studentList.Add(new Student()
        {
            StudentId = 2,
            Name = "John Doe",
            Department = "IT",
            Score = 620
        });

        _studentList.Add(new Student()
        {
            StudentId = 3,
            Name = "Aria Cruz",
            Department = "ME",
            Score = 840
        });


        _studentList.Add(new Student()
        {
            StudentId = 4,
            Name = "Yoshi Latimer",
            Department = "ME",
            Score = 450
        });



        CollectionViewSource viewSource = new CollectionViewSource();
        viewSource.GroupDescriptions.Add(new PropertyGroupDescription("Department"));
        viewSource.Source = _studentList; ;
        dataGrid.ItemsSource = viewSource.View;
    }

  public class Student
    {
        public int StudentId{ get; set; }
        public string Name { get; set; }
        public string Department { get; set; }
        public int Score { get; set; }
    }

when i am trying to edit the score or name in first any one of the department,after editing that row jumps to down.

Need a help on this.

  • 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-22T16:15:45+00:00Added an answer on May 22, 2026 at 4:15 pm

    This Solves my problem,I have added SortDescription to CollectionViewSource.

            CollectionViewSource viewSource = new CollectionViewSource();
            viewSource.GroupDescriptions.Add(new PropertyGroupDescription("Department"));
            viewSource.SortDescriptions.Add(new System.ComponentModel.SortDescription("Department", System.ComponentModel.ListSortDirection.Ascending));
            viewSource.SortDescriptions.Add(new System.ComponentModel.SortDescription("StudentId", System.ComponentModel.ListSortDirection.Ascending));
            viewSource.Source = _studentList; ;
            dataGrid.ItemsSource = viewSource.View;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my xaml code. <sdk:DataGrid x:Name=dgMarks CanUserResizeColumns=False SelectionMode=Single AutoGenerateColumns=False VerticalAlignment=Top IsReadOnly=True Margin=13,44,0,0 RowDetailsVisibilityChanged=dgMarks_RowDetailsVisibilityChanged
I have the following XAML Code: <sdk:DataGrid Margin=58,8,52,18 Name=dataGridTickets> <sdk:DataGrid.Columns> <sdk:DataGridTextColumn x:Name=ticketNoColumn Header=Ticket No.
I have quastion about DataGrid in WPF .NET 4. Here is XAML code with
How to bind a DataGrid to a DataTable in C# code behind? (All controls
I am creating the DataGrid and RowDetailsTemplate in code, so I don't have XAML
I'm defining a datagrid's RowDetailsTemplate in the following way: RowDetailsTemplate={StaticResource defaultTemplate} where <UserControl.Resources> <DataTemplate
This is a part of my code: <ribbon:RibbonWindow x:Class=MainWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:sys=clr-namespace:System;assembly=mscorlib xmlns:ribbon=clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary x:Name=RibbonWindow
I'm using a DataGrid inside a StackPanel inside a Grid which causes the GridView
In a True MVVM model we do not expect any code behind in xaml.cs
I have 2 silverlight controls on a form; datagrid which is bound to list

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.