Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF row height binding stops working after user uses GridSplitter

I have a grid with four rows:

<Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>                
            <RowDefinition Height="{Binding DocumentsHeight}"/>
            <RowDefinition Height="Auto"/> - GRIDSPLITTER
            <RowDefinition Height="{Binding ApprovedDocumentsHeight}" /> 
</Grid.RowDefinitions>

The dynamic resizing of rows works fine, heights are binded to strings with values like "5*". But when the user uses the GridSplitter, the binding stops working, getters are not called after next notify when I want to change the size of rows. Does anybody know where is the problem?

Thanks for help.

like image 302
user2849936 Avatar asked Nov 21 '13 14:11

user2849936


1 Answers

If you are binding to anything besides a GridLength, the binding will break. You can either bind to a GridLength property like this...

   private double documentsHeight = 100;

   public GridLength DocumentsHeight
    {
        get { return this.GridLength(this.documentsHeight); }
        set { this.documentsHeight = value.Value; }
    }

Also you'll need to set Mode=TwoWay on your binding.

like image 123
HexHead Avatar answered Sep 24 '22 23:09

HexHead