Answered by:
ListBox / GridSplitter resize problem when grid columns have MinWidth

Question
-
Hi,
I have come across some strange behaviour when using a GridSplitter and a ListBox which contains large items (longer than the visible area) and the grid columns have a minimum width defined.
The problem is quite difficult to explain, so I have put together a sample project which demonstrates it. This can be downloaded from http://cid-a65709b19f08d61a.office.live.com/browse.aspx/Sample%20projects. It is the GridSplitter.rar file.
This is what you have to do to recreate the problem.
- After the application has started, maximise the window
- Drag the GridSplitter as far to the right as possible
- Minimise the window again
After doing this you will see that the buttons in the right column have been pushed off the window. Initially I was also unable to adjust the GridSplitter after following this procedure. I got around this problem by setting ShowPreview=True.
The problem does not happen if the ListBox does not have a horizontal scroll bar, so I am not certain if the problem is with the ListBox, GridSplitter or the combination of both.
I have seen other posts with reference to the GridSplitter resizing so expect it is the GridSplitter which is causing the problem. Unfotunately, these posts either do not have a solution or do not correct the problem I am experiencing.
Thanks,
DocKimbleMonday, January 10, 2011 10:38 AM
Answers
-
Hi DocKimble,
After some serious research, I narrowed down the cause of this issue. It's not related to the GridSplitter or ListBox but it's a layout issue of the Grid itself.
I have filed a bug report at the Connect site for this issue. Here is the link. If you are interested for the response from the product team, you can add that page to your watch list by click a button on the top-right corner on that page. You can also add a Vote to that post which will raise it to a higher priority.
Since I have already explained the root cause of the issue in that connect post, in this thread I will only focus on the relation between that layout issue and your original quesition.
The ListBox in your code is acting as a large element that cannot be completed rendered as I stated as the condition 4 in the connect post. And the ListBox control itself is not related to the problem.
The GridSplitter in your code will change the ratio of the star-sizing columns, which makes the condition 3 in the connect post to happen when the window is scaled down. And the GridSplitter itself is not related to the problem either.
Although the issue in that connect post is hard to workaround, fortunately, it seems you do not need to always keep the star-sizing ratio in the grid since you have a GridSplitter in your code. So I am wondering whether you can avoid star-sizing in your code to workaround this issue? You can use pixels to define the initial size, or maybe you can also subscribe to Grid's loaded and sizechanged event to do some adjustment to the column size.
Hope this helps.
Best regards,
Min Zhu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marked as answer by Min Zhu Friday, January 21, 2011 1:43 AM
Friday, January 14, 2011 8:26 AM -
Hi Min,
Thank you for doing this research and raising the bug report.
I did try not using star-sizing. Unfortunately, when I did this one of the columns did not respect the MinWidth.
The problem can be recoverd by maximising the window again before doing the resize, so at least there is a work around.
DocKimble
- Marked as answer by Min Zhu Friday, January 21, 2011 1:42 AM
Friday, January 14, 2011 9:03 AM
All replies
-
Hi DocKimble,
Thank you for your question.
I am currently looking into this issue and will give you an update as soon as possible.
Thank you for your understanding and support.Edit: This seems to be a layout issue with Grid. Could you please report this issue at MS Connect Site?
I am working on a workaround and will update this thread as soon as possible.
Best regards,
Min Zhu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Tuesday, January 11, 2011 9:42 AM -
Hi DocKimble,
After some serious research, I narrowed down the cause of this issue. It's not related to the GridSplitter or ListBox but it's a layout issue of the Grid itself.
I have filed a bug report at the Connect site for this issue. Here is the link. If you are interested for the response from the product team, you can add that page to your watch list by click a button on the top-right corner on that page. You can also add a Vote to that post which will raise it to a higher priority.
Since I have already explained the root cause of the issue in that connect post, in this thread I will only focus on the relation between that layout issue and your original quesition.
The ListBox in your code is acting as a large element that cannot be completed rendered as I stated as the condition 4 in the connect post. And the ListBox control itself is not related to the problem.
The GridSplitter in your code will change the ratio of the star-sizing columns, which makes the condition 3 in the connect post to happen when the window is scaled down. And the GridSplitter itself is not related to the problem either.
Although the issue in that connect post is hard to workaround, fortunately, it seems you do not need to always keep the star-sizing ratio in the grid since you have a GridSplitter in your code. So I am wondering whether you can avoid star-sizing in your code to workaround this issue? You can use pixels to define the initial size, or maybe you can also subscribe to Grid's loaded and sizechanged event to do some adjustment to the column size.
Hope this helps.
Best regards,
Min Zhu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marked as answer by Min Zhu Friday, January 21, 2011 1:43 AM
Friday, January 14, 2011 8:26 AM -
Hi Min,
Thank you for doing this research and raising the bug report.
I did try not using star-sizing. Unfortunately, when I did this one of the columns did not respect the MinWidth.
The problem can be recoverd by maximising the window again before doing the resize, so at least there is a work around.
DocKimble
- Marked as answer by Min Zhu Friday, January 21, 2011 1:42 AM
Friday, January 14, 2011 9:03 AM -
Hi DocKimble,
I am glad to hear that you have found a workaround.
Please feel free to let us know if you have other doubts or concerns about this issue. We are happy to be of assistance.
Have a great day!
Best regards,
Min Zhu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Tuesday, January 18, 2011 6:14 AM -
This post came up when I wanted to ask a similar question, so I'll post my solutions if others run into the same problem.
I derived my own Grid control and modified the ArrangeOverride and the MeasureOverride methods and it seems to work properly now:
http://arguslib.codeplex.com/SourceControl/latest#ArgusLib/ArgusLib.Controls.WPF/Grid.cs
https://fraktalysator.codeplex.com
- Edited by ArgusMagnus Thursday, May 8, 2014 11:52 AM
Thursday, May 8, 2014 11:51 AM