20 June, 2010

Silverlight "Expandable" grid with gridsplitter

a client needed a better user experience for a part of an application we had developed. The situation is as follows: A grid contains a control. The grid has three rows with a gridsplitter in the second row and the control in the third row. The control in question is a tabcontrol. Initially only the tabs of the tabcontrol are visible. The user can then drag the gridsplitter and reveal the content of the tab in the tabcontrol.
Now the gridsplitter does some strange stuff when it is dragged to get the correct height for the rows. It switches the height of the second row to an absolute value. This might work for some scenarios but not for mine. So I started to tinker with it and i think i have a fairly nice solution. I wait for the gridsplitter to do its magic, copy the height to the control and reset the height of the row to Auto. This way the (tab)control tells the grid row what the height should be and I can still use the gridsplitter for the draging part.
This solution is specific for the tabcontrol but I'm interested if this can be made more generic. How would you do this?

the source code VS2010: TabgridSplitter