I did not check, but I am sure that the currently accepted answer from AresAvatar will not work if you resize the rows / columns using the arrows on the keyboard (paying attention to the grid separator). This is a rare but possible case that you should foresee in your statement.
When moving the grid divider (using drag'n'drop or using the arrows on the keyboard), it changes the Width / Height dependency properties for ColumnDefinitions / RowDefinitions grid. You can easily register a handler for this property change:
var heightDescriptor = DependencyPropertyDescriptor.FromProperty(RowDefinition.HeightProperty, typeof(ItemsControl)); heightDescriptor.AddValueChanged(myGrid.RowDefinitions[0], HeightChanged);
(This fragment, for example, will resize the track in the first row of the grid).
Then you can handle the resizing in a handler that will work anyway.
private void HeightChanged(object sender, EventArgs e) {
As a rule, it is not recommended to rely on user input (drag and drop, keyboard input ...) to handle logical or visual actions / events, since there are almost always several ways to perform the same actions using different inputs (mouse, keyboard , touch screen, easy to use tools ...).
source share