csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.2 KiB
40 lines
1.2 KiB
using System.Linq;
|
|
using System.Reactive.Linq;
|
|
using Avalonia.Controls;
|
|
using Avalonia.UnitTests;
|
|
using Avalonia.VisualTree;
|
|
using Xunit;
|
|
|
|
namespace Avalonia.Markup.Xaml.UnitTests.Data
|
|
{
|
|
public class BindingTests_TemplatedParent : XamlTestBase
|
|
{
|
|
[Fact]
|
|
public void TemplateBinding_With_Null_Path_Works()
|
|
{
|
|
using (UnitTestApplication.Start(TestServices.StyledWindow))
|
|
{
|
|
var xaml = @"
|
|
<Window xmlns='https://github.com/avaloniaui'
|
|
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
|
|
xmlns:local='clr-namespace:Avalonia.Markup.Xaml.UnitTests.Xaml;assembly=Avalonia.Markup.Xaml.UnitTests'>
|
|
<Button Name='button'>
|
|
<Button.Template>
|
|
<ControlTemplate>
|
|
<TextBlock Tag='{TemplateBinding}'/>
|
|
</ControlTemplate>
|
|
</Button.Template>
|
|
</Button>
|
|
</Window>";
|
|
var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml);
|
|
var button = window.FindControl<Button>("button");
|
|
|
|
window.ApplyTemplate();
|
|
button.ApplyTemplate();
|
|
|
|
var textBlock = (TextBlock)button.GetVisualChildren().Single();
|
|
Assert.Same(button, textBlock.Tag);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|