diff --git a/src/Avalonia.Controls/Grid.cs b/src/Avalonia.Controls/Grid.cs
index 54fcefeb3f..5f194bdd71 100644
--- a/src/Avalonia.Controls/Grid.cs
+++ b/src/Avalonia.Controls/Grid.cs
@@ -194,6 +194,16 @@ namespace Avalonia.Controls
///
private GridLayout.MeasureResult _rowMeasureCache;
+ ///
+ /// Gets the row layout as of the last measure.
+ ///
+ private GridLayout _rowLayoutCache;
+
+ ///
+ /// Gets the column layout as of the last measure.
+ ///
+ private GridLayout _columnLayoutCache;
+
///
/// Measures the grid.
///
@@ -253,6 +263,9 @@ namespace Avalonia.Controls
// Cache the measure result and return the desired size.
_columnMeasureCache = columnResult;
_rowMeasureCache = rowResult;
+ _rowLayoutCache = rowLayout;
+ _columnLayoutCache = columnLayout;
+
return new Size(columnResult.DesiredLength, rowResult.DesiredLength);
// Measure each child only once.
@@ -299,13 +312,11 @@ namespace Avalonia.Controls
// arrow back to any statements and re-run them without any side-effect.
var (safeColumns, safeRows) = GetSafeColumnRows();
- var columnLayout = new GridLayout(ColumnDefinitions);
- var rowLayout = new GridLayout(RowDefinitions);
-
+ var columnLayout = _columnLayoutCache;
+ var rowLayout = _rowLayoutCache;
// Calculate for arrange result.
var columnResult = columnLayout.Arrange(finalSize.Width, _columnMeasureCache);
var rowResult = rowLayout.Arrange(finalSize.Height, _rowMeasureCache);
-
// Arrange the children.
foreach (var child in Children.OfType())
{
@@ -315,7 +326,6 @@ namespace Avalonia.Controls
var y = Enumerable.Range(0, row).Sum(r => rowResult.LengthList[r]);
var width = Enumerable.Range(column, columnSpan).Sum(c => columnResult.LengthList[c]);
var height = Enumerable.Range(row, rowSpan).Sum(r => rowResult.LengthList[r]);
-
child.Arrange(new Rect(x, y, width, height));
}
diff --git a/src/Avalonia.Styling/Styling/Setter.cs b/src/Avalonia.Styling/Styling/Setter.cs
index 1a78e0f4d7..31b685f6b1 100644
--- a/src/Avalonia.Styling/Styling/Setter.cs
+++ b/src/Avalonia.Styling/Styling/Setter.cs
@@ -158,18 +158,11 @@ namespace Avalonia.Styling
var activated = new ActivatedObservable(activator, sourceInstance.Observable, description);
return InstancedBinding.OneWay(activated, BindingPriority.StyleTrigger);
}
- case BindingMode.OneWayToSource:
- {
- var activated = new ActivatedSubject(activator, sourceInstance.Subject, description);
- return InstancedBinding.OneWayToSource(activated, BindingPriority.StyleTrigger);
- }
- case BindingMode.TwoWay:
+ default:
{
var activated = new ActivatedSubject(activator, sourceInstance.Subject, description);
- return InstancedBinding.TwoWay(activated, BindingPriority.StyleTrigger);
+ return new InstancedBinding(activated, sourceInstance.Mode, BindingPriority.StyleTrigger);
}
- default:
- throw new NotSupportedException("Unsupported BindingMode.");
}
}