Browse Source
Fixed BindingExtension.TargetNullValue default value.
pull/3359/head
José Pedro
6 years ago
No known key found for this signature in database
GPG Key ID: B8247B9301707B83
2 changed files with
25 additions and
3 deletions
-
src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/BindingExtension.cs
-
tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/BindingExtensionTests.cs
|
|
|
@ -87,7 +87,7 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions |
|
|
|
public string StringFormat { get; set; } |
|
|
|
|
|
|
|
public RelativeSource RelativeSource { get; set; } |
|
|
|
|
|
|
|
public object TargetNullValue { get; set; } |
|
|
|
|
|
|
|
public object TargetNullValue { get; set; } = AvaloniaProperty.UnsetValue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -38,7 +38,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions |
|
|
|
Assert.Equal("foobar", textBlock.Text); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void BindingExtension_Binds_To_TargetNullValue() |
|
|
|
{ |
|
|
|
@ -65,6 +65,28 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void BindingExtension_TargetNullValue_UnsetByDefault() |
|
|
|
{ |
|
|
|
using (StyledWindow()) |
|
|
|
{ |
|
|
|
var xaml = @"
|
|
|
|
<Window xmlns='https://github.com/avaloniaui'
|
|
|
|
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
|
|
|
|
<TextBlock Name='textBlock' IsVisible='{Binding Foo, Converter={x:Static ObjectConverters.IsNotNull}}'/> |
|
|
|
</Window>";
|
|
|
|
|
|
|
|
var loader = new AvaloniaXamlLoader(); |
|
|
|
var window = (Window)loader.Load(xaml); |
|
|
|
var textBlock = window.FindControl<TextBlock>("textBlock"); |
|
|
|
|
|
|
|
window.DataContext = new FooBar(); |
|
|
|
window.Show(); |
|
|
|
|
|
|
|
Assert.Equal(false, textBlock.IsVisible); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private class FooBar |
|
|
|
{ |
|
|
|
public object Foo { get; } = null; |
|
|
|
|