A cross-platform UI framework for .NET
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.
 
 
 

47 lines
1.3 KiB

using System;
using Moq;
using Avalonia.Controls;
using Avalonia.Data;
using Avalonia.Styling;
using Xunit;
using System.Reactive.Disposables;
using Avalonia.Markup.Data;
using Avalonia.Controls.Primitives;
namespace Avalonia.Markup.UnitTests.Data
{
public class BindingTests_Self
{
[Fact]
public void Binding_To_Property_On_Self_Should_Work()
{
var target = new TextBlock
{
Tag = "Hello World!",
[!TextBlock.TextProperty] = new Binding("Tag")
{
RelativeSource = new RelativeSource(RelativeSourceMode.Self)
},
};
Assert.Equal("Hello World!", target.Text);
}
[Fact]
public void TwoWay_Binding_To_Property_On_Self_Should_Work()
{
var target = new TextBlock
{
Tag = "Hello World!",
[!TextBlock.TextProperty] = new Binding("Tag", BindingMode.TwoWay)
{
RelativeSource = new RelativeSource(RelativeSourceMode.Self)
},
};
Assert.Equal("Hello World!", target.Text);
target.Text = "Goodbye cruel world :(";
Assert.Equal("Goodbye cruel world :(", target.Text);
}
}
}