|
|
|
@ -7,6 +7,31 @@ namespace Avalonia.Markup.Xaml.UnitTests.Xaml |
|
|
|
{ |
|
|
|
public class DataTemplateTests : XamlTestBase |
|
|
|
{ |
|
|
|
[Fact] |
|
|
|
public void DataTemplate_Can_Be_Empty() |
|
|
|
{ |
|
|
|
using (UnitTestApplication.Start(TestServices.StyledWindow)) |
|
|
|
{ |
|
|
|
var xaml = @"
|
|
|
|
<Window xmlns='https://github.com/avaloniaui'
|
|
|
|
xmlns:sys='clr-namespace:System;assembly=netstandard' |
|
|
|
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
|
|
|
|
<Window.DataTemplates> |
|
|
|
<DataTemplate DataType='{x:Type sys:String}' /> |
|
|
|
</Window.DataTemplates> |
|
|
|
<ContentControl Name='target' Content='Foo'/> |
|
|
|
</Window>";
|
|
|
|
var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); |
|
|
|
var target = window.FindControl<ContentControl>("target"); |
|
|
|
|
|
|
|
window.ApplyTemplate(); |
|
|
|
target.ApplyTemplate(); |
|
|
|
((ContentPresenter)target.Presenter).UpdateChild(); |
|
|
|
|
|
|
|
Assert.Null(target.Presenter.Child); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void DataTemplate_Can_Contain_Name() |
|
|
|
{ |
|
|
|
|