private void UpdateRect(object sender, ElapsedEventArgs e) { Application.Current.Dispatcher.Invoke( delegate { var mousePos = FormsControl.MousePosition; _cropRegion.X2 = mousePos.X; _cropRegion.Y2 = mousePos.Y; Row0.SetValue(RowDefinition.HeightProperty, new GridLength(_cropRegion.TopLeft.Y + TopLeftOffset, GridUnitType.Pixel)); Row1.SetValue(RowDefinition.HeightProperty, new GridLength(_cropRegion.BottomRight.Y - _cropRegion.TopLeft.Y, GridUnitType.Pixel)); Row2.SetValue(RowDefinition.HeightProperty, new GridLength(1, GridUnitType.Star)); Col0.SetValue(ColumnDefinition.WidthProperty, new GridLength(_cropRegion.TopLeft.X + TopLeftOffset, GridUnitType.Pixel)); Col1.SetValue(ColumnDefinition.WidthProperty, new GridLength(_cropRegion.BottomRight.X - _cropRegion.TopLeft.X, GridUnitType.Pixel)); Col2.SetValue(ColumnDefinition.WidthProperty, new GridLength(1, GridUnitType.Star)); } ); }