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

  • Home
  • SEARCH
  • 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 497959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:49:54+00:00 2026-05-13T05:49:54+00:00

Im using the wpf datagrid and am looking for a way to set the

  • 0

Im using the wpf datagrid and am looking for a way to set the height on all of the rows when the user adjusts one of them. I know the datagrid has a RowHeight property that sets all of the row heights at once, but the how of catching an individual row height changed escapes me

  • 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-13T05:49:54+00:00Added an answer on May 13, 2026 at 5:49 am

    I arrived on this by trial and error, so long ass you are using an ItemsSource data source it should work fine.
    It should work with virtual rows and causes only a brief visual pause and it switches over (this seems mainly down to column autogeneration so can be avoided).

    As hacks go it has the advantage of simplicity and the use of mechanics which are not expected to change.

    The heuristic on user triggering of the action might be improved but it has not failed on me yet.

    using Microsoft.Windows.Controls;
    using Microsoft.Windows.Controls.Primitives;
    
    public static class DataGridExtensions
    {
        public static void LinkRowHeightsToUserChange(this DataGrid dataGrid)
        {
            double? heightToApply = null;
            bool userTriggered = false;
    
            if (dataGrid.RowHeaderStyle == null)
                dataGrid.RowHeaderStyle = new Style(typeof(DataGridRowHeader));
            if (dataGrid.RowStyle == null)
                dataGrid.RowStyle = new Style(typeof(DataGridRow));
    
            dataGrid.RowStyle.Setters.Add(new EventSetter()
            {
                Event = DataGridRow.SizeChangedEvent,
                Handler = new SizeChangedEventHandler((r, sizeArgs) =>
                {
                    if (userTriggered && sizeArgs.HeightChanged)
                            heightToApply = sizeArgs.NewSize.Height;
                })
            });
            dataGrid.RowHeaderStyle.Setters.Add(new EventSetter()
            {
                Event = DataGridRowHeader.PreviewMouseDownEvent,
                Handler = new MouseButtonEventHandler(
                    (rh,e) => userTriggered = true)
            });
            dataGrid.RowHeaderStyle.Setters.Add(new EventSetter()
            {
                Event = DataGridRowHeader.MouseLeaveEvent,
                Handler = new MouseEventHandler((o, mouseArgs) =>
                {
                    if (heightToApply.HasValue)
                    {
                        userTriggered = false;
                        var itemsSource = dataGrid.ItemsSource;
                        dataGrid.ItemsSource = null;
                        dataGrid.RowHeight = heightToApply.Value;
                        dataGrid.ItemsSource = itemsSource;
                        heightToApply = null;
                    }
                })
            });
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the WPF DataGrid, and I'd like to know if there is any
Using WPF, I have a TreeView control that I want to set its ItemTemplate
Anyone using WPF for real LOB applications? We have all seen the clever demos
My company is just starting to look at using WPF for migrating all of
I'm using a WPF WebBrowser control to preview HTML typed by the user. example...
I'm looking for opinion on using Canvas vs. Grid panels in WPF. I need
I want to enable the user to highlight a row on the WPF DataGrid
I am using the WPF Datagrid from Codeplex. I am able to style the
I want a simple sample program that nests collections within collections using Wpf DataGrid.
Using the WPF DataGrid I have the need to change various display and related

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.