© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
1 reply
Thalnos

❔ Dynamic sizing of Grid Rows

I am faced with a UI problem in WPF and looking for some ideas on how to deal with it:

I have a grid with 3 rows. a row contains a DataGrid that can be visible or not depending whether it has data. I want to size the rows dynamicly, in respect to how many grid rows have data - that is when there is only one row it shall take full height, when its 3 it should be commonly distributed etc.

My initial approach would be to set the height of these rows to
*
*
which will use dynamic sizing in respect to available space and then add or remove rows to grid in the code-behind. I'm just concerned whether this is a good idea because I can imagine that adding and removing rows to a grid at runtime costs a lot.

I could also always use 3 rows and just change the height of those that are empty to
0
0
tho.

those are the two ideas I have. What do you guys think?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Sizing of Byte Arrays
C#CC# / help
3y ago
EF Core Querying a List of Rows
C#CC# / help
4y ago
✅ Grid Layout
C#CC# / help
11mo ago
❔ Grid Employee
C#CC# / help
3y ago