Reputation: 11
I want to save the GridSplitter position in the ViewModel so that when the user returns to the DataTemplate, the Grid column settings are preserved. Binding to the GridLength property doesn't help, as it records the value in pixels, and I need the Splitter not to be able to move beyond the window boundaries, and also to preserve column proportions when the window is resized.
If someone can help write the corresponding converter, I would be very grateful, as I couldn't manage it. I hope my issue is clear.I am ready to answer questions in the comments.
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="Purple" x:Name="Grid" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0" Background="Red"/>
<Border Background="Green" Grid.Column="2" />
<GridSplitter Width="5" Background="Black" Grid.Column="1" VerticalAlignment="Stretch" ResizeBehavior="PreviousAndNext"/>
</Grid>
For example, I set a fixed value for the first column In that case, if you move the splitter to the right, it can go beyond the window boundaries I also tried binding MaxWidth to the maximum values of objects inside the Grid, but it didn't help.
Upvotes: 0
Views: 114