I have a UserControl that arranges templated items on a grid (based on the answer from this question). Now I want to make the columns/rows of that grid resizable.
Right now, I have a bit of hack going where I detect mouse events and calculate if the user clicks near a border. If so, it adjust the appropriate column. This mostly works, but I'm having problems with relatively slow MouseMove events firing making it difficult for the user to click in the right spot. Also, I can't expand the size of the last row/column since the mouse now moves outside of the control area where I can't track it (although I could probably fix this with more work).
A better solution would be to just add GridSplitters to each column/row. The problem is, my UserControl uses an ItemsControl and DataTemplate to create the items so I'm having troubles figuring out how to add the splitter. Is it possible for me to modify the user defined template? Is there some other way to add the splitters?
* EDIT *
Here is an example of what I would like to do (if the grid cells were defined manually, instead of via ItemsControl). Note that this example still doesn't solve the resize last row problem.
<Grid
Grid.Row="2" Grid.Column="1"
>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBox Text="Row 0" Grid.Row="0"/>
<GridSplitter
Grid.Row="0"
Height="5"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom"
Background="Transparent"/>
<TextBox Text="Row 1" Grid.Row="1"/>
<GridSplitter
Grid.Row="1"
Height="5"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom"
Background="Transparent"/>
<TextBox Text="Row 2" Grid.Row="2"/>
<GridSplitter
Grid.Row="2"
Height="5"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom"
Background="Transparent"/>
</Grid>