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.
42 lines
1.5 KiB
42 lines
1.5 KiB
using System.Linq;
|
|
using Avalonia.Controls.Templates;
|
|
using Avalonia.Data;
|
|
using Avalonia.Markup.Xaml.Templates;
|
|
using Avalonia.UnitTests;
|
|
using Xunit;
|
|
|
|
namespace Avalonia.Markup.Xaml.UnitTests.Xaml
|
|
{
|
|
public class TreeDataTemplateTests : XamlTestBase
|
|
{
|
|
[Fact]
|
|
public void Binding_Should_Be_Assigned_To_ItemsSource_Instead_Of_Bound()
|
|
{
|
|
using (UnitTestApplication.Start(TestServices.MockPlatformWrapper))
|
|
{
|
|
var xaml = "<DataTemplates xmlns='https://github.com/avaloniaui'><TreeDataTemplate DataType='Control' ItemsSource='{Binding}'/></DataTemplates>";
|
|
var templates = (DataTemplates)AvaloniaRuntimeXamlLoader.Load(xaml);
|
|
var template = (TreeDataTemplate)(templates.First());
|
|
|
|
Assert.IsType<ReflectionBinding>(template.ItemsSource);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void XDataType_Should_Be_Assigned_To_Clr_Property()
|
|
{
|
|
using (UnitTestApplication.Start(TestServices.MockPlatformWrapper))
|
|
{
|
|
var xaml = @"
|
|
<DataTemplates xmlns='https://github.com/avaloniaui'
|
|
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
|
|
<TreeDataTemplate x:DataType='x:String' />
|
|
</DataTemplates>";
|
|
var templates = (DataTemplates)AvaloniaRuntimeXamlLoader.Load(xaml);
|
|
var template = (TreeDataTemplate)(templates.First());
|
|
|
|
Assert.Equal(typeof(string), template.DataType);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|