Browse Source

Merge branch 'master' into fixes/DataGridPageForAutoRow

pull/2618/head
Benedikt Schroeder 7 years ago
committed by GitHub
parent
commit
191b5dd5b3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      src/Avalonia.Controls.DataGrid/DataGridRow.cs
  2. 2
      src/Markup/Avalonia.Markup.Xaml/XamlIl/xamlil.github
  3. 51
      tests/Avalonia.Markup.Xaml.UnitTests/Xaml/XamlIlTests.cs

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

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

2
src/Markup/Avalonia.Markup.Xaml/XamlIl/xamlil.github

@ -1 +1 @@
Subproject commit a73c5234831267b23160e01a9fbc83be633f69fc
Subproject commit 610cda30c69e32e83c8235060606480904c937bc

51
tests/Avalonia.Markup.Xaml.UnitTests/Xaml/XamlIlTests.cs

@ -158,6 +158,55 @@ namespace Avalonia.Markup.Xaml.UnitTests
Assert.Equal("321", loaded.Test);
}
void AssertThrows(Action callback, Func<Exception, bool> check)
{
try
{
callback();
}
catch (Exception e) when (check(e))
{
return;
}
throw new Exception("Expected exception was not thrown");
}
public static object SomeStaticProperty { get; set; }
[Fact]
public void Bug2570()
{
SomeStaticProperty = "123";
AssertThrows(() => new AvaloniaXamlLoader() {IsDesignMode = true}
.Load(@"
<UserControl
xmlns='https://github.com/avaloniaui'
xmlns:d='http://schemas.microsoft.com/expression/blend/2008'
xmlns:tests='clr-namespace:Avalonia.Markup.Xaml.UnitTests'
d:DataContext='{x:Static tests:XamlIlTests.SomeStaticPropery}'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'/>", typeof(XamlIlTests).Assembly),
e => e.Message.Contains("Unable to resolve ")
&& e.Message.Contains(" as static field, property, constant or enum value"));
}
[Fact]
public void Design_Mode_DataContext_Should_Be_Set()
{
SomeStaticProperty = "123";
var loaded = (UserControl)new AvaloniaXamlLoader() {IsDesignMode = true}
.Load(@"
<UserControl
xmlns='https://github.com/avaloniaui'
xmlns:d='http://schemas.microsoft.com/expression/blend/2008'
xmlns:tests='clr-namespace:Avalonia.Markup.Xaml.UnitTests'
d:DataContext='{x:Static tests:XamlIlTests.SomeStaticProperty}'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'/>", typeof(XamlIlTests).Assembly);
Assert.Equal(Design.GetDataContext(loaded), SomeStaticProperty);
}
}
public class XamlIlBugTestsEventHandlerCodeBehind : Window
@ -188,7 +237,7 @@ namespace Avalonia.Markup.Xaml.UnitTests
((ItemsControl)Content).Items = new[] {"123"};
}
}
public class XamlIlClassWithCustomProperty : UserControl
{
public string Test { get; set; }

Loading…
Cancel
Save