|
@@ -47,19 +47,29 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions
|
|
|
var xaml = @"
|
|
var xaml = @"
|
|
|
<Window xmlns='https://github.com/avaloniaui'
|
|
<Window xmlns='https://github.com/avaloniaui'
|
|
|
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
|
|
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
|
|
|
- <TextBlock Name='textBlock' Text='{Binding Source={x:Null}, TargetNullValue='foobar'}'/>
|
|
|
|
|
|
|
+ <Window.Resources>
|
|
|
|
|
+ <x:String x:Key='text'>foobar</x:String>
|
|
|
|
|
+ </Window.Resources>
|
|
|
|
|
+
|
|
|
|
|
+ <TextBlock Name='textBlock' Text='{Binding Foo, TargetNullValue={StaticResource text}}'/>
|
|
|
</Window>";
|
|
</Window>";
|
|
|
|
|
|
|
|
var loader = new AvaloniaXamlLoader();
|
|
var loader = new AvaloniaXamlLoader();
|
|
|
var window = (Window)loader.Load(xaml);
|
|
var window = (Window)loader.Load(xaml);
|
|
|
var textBlock = window.FindControl<TextBlock>("textBlock");
|
|
var textBlock = window.FindControl<TextBlock>("textBlock");
|
|
|
|
|
|
|
|
|
|
+ window.DataContext = new FooBar();
|
|
|
window.Show();
|
|
window.Show();
|
|
|
|
|
|
|
|
Assert.Equal("foobar", textBlock.Text);
|
|
Assert.Equal("foobar", textBlock.Text);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private class FooBar
|
|
|
|
|
+ {
|
|
|
|
|
+ public object Foo { get; } = null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private IDisposable StyledWindow(params (string, string)[] assets)
|
|
private IDisposable StyledWindow(params (string, string)[] assets)
|
|
|
{
|
|
{
|
|
|
var services = TestServices.StyledWindow.With(
|
|
var services = TestServices.StyledWindow.With(
|