Skip to content

Instantly share code, notes, and snippets.

@grokys
Created September 10, 2016 11:28
Show Gist options
  • Select an option

  • Save grokys/500d582773b1f6f1702efc58c56f7476 to your computer and use it in GitHub Desktop.

Select an option

Save grokys/500d582773b1f6f1702efc58c56f7476 to your computer and use it in GitHub Desktop.
[Fact]
public void Infinite_Loop()
{
using (UnitTestApplication.Start(TestServices.StyledWindow))
{
var xaml = @"
<Window xmlns='https://github.com/avaloniaui'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
Width='100' Height='100'>
<ListBox Items='{Binding}'>
<ListBox.ItemTemplate>
<DataTemplate>
<Button Content='{Binding}'/>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.Styles>
<Style Selector='Button'>
<Setter Property='Template'>
<Setter.Value>
<ControlTemplate>
<TextBlock Text='{TemplateBinding Text}'/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.Styles>
</ListBox>
</Window>";
var loader = new AvaloniaXamlLoader();
var window = (Window)loader.Load(xaml);
var listBox = (ListBox)window.Content;
window.DataContext = new[] { new Item("foo") };
LayoutManager.Instance.ExecuteInitialLayoutPass(window);
var listBoxItem = (ListBoxItem)listBox.GetLogicalChildren().Single();
var button = (Button)listBoxItem.Presenter.Child;
var textBlock = (TextBlock)button.GetVisualChildren().Single();
Assert.Null(textBlock.Text);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment