Browse Source

Merge pull request #2617 from sdoroff/datagrid-rowdetails

DataGrid RowDetail Fix
pull/2629/head
Steven Kirk 7 years ago
committed by GitHub
parent
commit
c304a346ec
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      src/Avalonia.Controls.DataGrid/DataGridRow.cs

25
src/Avalonia.Controls.DataGrid/DataGridRow.cs

@ -881,10 +881,10 @@ namespace Avalonia.Controls
&& (double.IsNaN(_detailsContent.Height)) && (double.IsNaN(_detailsContent.Height))
&& (AreDetailsVisible) && (AreDetailsVisible)
&& (!double.IsNaN(_detailsDesiredHeight)) && (!double.IsNaN(_detailsDesiredHeight))
&& !DoubleUtil.AreClose(_detailsContent.Bounds.Height, _detailsDesiredHeight) && !DoubleUtil.AreClose(_detailsContent.Bounds.Inflate(_detailsContent.Margin).Height, _detailsDesiredHeight)
&& Slot != -1) && Slot != -1)
{ {
_detailsDesiredHeight = _detailsContent.Bounds.Height; _detailsDesiredHeight = _detailsContent.Bounds.Inflate(_detailsContent.Margin).Height;
if (true) if (true)
{ {
@ -943,6 +943,16 @@ namespace Avalonia.Controls
_previousDetailsHeight = newValue.Height; _previousDetailsHeight = newValue.Height;
} }
} }
private void DetailsContent_BoundsChanged(Rect newValue)
{
if(_detailsContent != null)
DetailsContent_SizeChanged(newValue.Inflate(_detailsContent.Margin));
}
private void DetailsContent_MarginChanged(Thickness newValue)
{
if (_detailsContent != null)
DetailsContent_SizeChanged(_detailsContent.Bounds.Inflate(newValue));
}
//TODO Animation //TODO Animation
// Sets AreDetailsVisible on the row and animates if necessary // Sets AreDetailsVisible on the row and animates if necessary
@ -997,7 +1007,7 @@ namespace Avalonia.Controls
} }
} }
} }
internal void ApplyDetailsTemplate(bool initializeDetailsPreferredHeight) internal void ApplyDetailsTemplate(bool initializeDetailsPreferredHeight)
{ {
if (_detailsElement != null && AreDetailsVisible) if (_detailsElement != null && AreDetailsVisible)
@ -1023,8 +1033,11 @@ namespace Avalonia.Controls
if (_detailsContent != null) if (_detailsContent != null)
{ {
_detailsContentSizeSubscription = _detailsContentSizeSubscription =
_detailsContent.GetObservable(BoundsProperty) System.Reactive.Disposables.StableCompositeDisposable.Create(
.Subscribe(DetailsContent_SizeChanged); _detailsContent.GetObservable(BoundsProperty)
.Subscribe(DetailsContent_BoundsChanged),
_detailsContent.GetObservable(MarginProperty)
.Subscribe(DetailsContent_MarginChanged));
_detailsElement.Children.Add(_detailsContent); _detailsElement.Children.Add(_detailsContent);
} }
} }
@ -1053,4 +1066,4 @@ namespace Avalonia.Controls
//TODO Styles //TODO Styles
} }

Loading…
Cancel
Save