|
|
|
@ -207,6 +207,33 @@ namespace Avalonia.Markup.Xaml.UnitTests |
|
|
|
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'/>", typeof(XamlIlTests).Assembly);
|
|
|
|
Assert.Equal(Design.GetDataContext(loaded), SomeStaticProperty); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Attached_Properties_From_Static_Types_Should_Work_In_Style_Setters_Bug_2561() |
|
|
|
{ |
|
|
|
using (UnitTestApplication.Start(TestServices.StyledWindow)) |
|
|
|
{ |
|
|
|
|
|
|
|
var parsed = (Window)AvaloniaXamlLoader.Parse(@"
|
|
|
|
<Window |
|
|
|
xmlns='https://github.com/avaloniaui'
|
|
|
|
xmlns:local='clr-namespace:Avalonia.Markup.Xaml.UnitTests;assembly=Avalonia.Markup.Xaml.UnitTests' |
|
|
|
> |
|
|
|
<Window.Styles> |
|
|
|
<Style Selector='TextBox'> |
|
|
|
<Setter Property='local:XamlIlBugTestsStaticClassWithAttachedProperty.TestInt' Value='100'/> |
|
|
|
</Style> |
|
|
|
</Window.Styles> |
|
|
|
<TextBox/> |
|
|
|
|
|
|
|
</Window> |
|
|
|
");
|
|
|
|
var tb = ((TextBox)parsed.Content); |
|
|
|
parsed.Show(); |
|
|
|
tb.ApplyTemplate(); |
|
|
|
Assert.Equal(100, XamlIlBugTestsStaticClassWithAttachedProperty.GetTestInt(tb)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public class XamlIlBugTestsEventHandlerCodeBehind : Window |
|
|
|
@ -272,4 +299,19 @@ namespace Avalonia.Markup.Xaml.UnitTests |
|
|
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
public static class XamlIlBugTestsStaticClassWithAttachedProperty |
|
|
|
{ |
|
|
|
public static readonly AvaloniaProperty TestIntProperty = AvaloniaProperty |
|
|
|
.RegisterAttached<Control, int>("TestInt", typeof(XamlIlBugTestsStaticClassWithAttachedProperty)); |
|
|
|
|
|
|
|
public static void SetTestInt(Control control, int value) |
|
|
|
{ |
|
|
|
control.SetValue(TestIntProperty, value); |
|
|
|
} |
|
|
|
|
|
|
|
public static int GetTestInt(Control control) |
|
|
|
{ |
|
|
|
return (int)control.GetValue(TestIntProperty); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|