✅ WPF Datagrid colums width
Hi, any idea why my column do not fit the whole width of my datagrid ?
https://paste.mod.gg/csupsvqrdjql/0
7 Replies
You have to go to heroic efforts to auto stretch columns in list controls. Essentially you'll have to bind to an ancestor and math, at least from my hobbyist experience, I did this years back though, so it's possible I did it wrong, or they may be a better way.
Thanks for your feedback, I've bound the width with his ancestors, it seems to be the best solution to my point of view. I've struggled so much for this 🤣
Did it work?
I recall needing to find the right ancestor, and it was not what I expected iirc, and it was a challenge to get the correct ancestor
Yup it seems to work, I've created a customContainerStyle to remove all the default parameters like padding, margin etc.. so my listBoxItem can fit the width of the listbox then I just have to get the ancestor of the datagrid which is listboxitem. I'm not sure to be very clear but I can share with you the code tomorrow
Sounds like a more mature solution than mine 🙂
It's exceedingly special we can't just say, stretch
the final solution i'll use with binding to width of his parent
ItemContaine Style :
👍