|
@@ -405,6 +405,41 @@ namespace Avalonia.Controls.UnitTests
|
|
|
Assert.Equal("bar", Assert.IsType<TextBlock>(target.ContentPart.Child).Tag);
|
|
|
}
|
|
|
|
|
|
+ [Fact]
|
|
|
+ public void Previous_ContentTemplate_Is_Not_Reused_When_TabItem_Changes()
|
|
|
+ {
|
|
|
+ int templatesBuilt = 0;
|
|
|
+
|
|
|
+ var target = new TabControl
|
|
|
+ {
|
|
|
+ Template = TabControlTemplate(),
|
|
|
+ Items =
|
|
|
+ {
|
|
|
+ TabItemFactory("First tab content"),
|
|
|
+ TabItemFactory("Second tab content"),
|
|
|
+ },
|
|
|
+ };
|
|
|
+
|
|
|
+ var root = new TestRoot(target);
|
|
|
+ ApplyTemplate(target);
|
|
|
+
|
|
|
+ target.SelectedIndex = 0;
|
|
|
+ target.SelectedIndex = 1;
|
|
|
+
|
|
|
+ Assert.Equal(2, templatesBuilt);
|
|
|
+
|
|
|
+ TabItem TabItemFactory(object content) => new()
|
|
|
+ {
|
|
|
+ Content = content,
|
|
|
+ ContentTemplate = new FuncDataTemplate<object>((actual, ns) =>
|
|
|
+ {
|
|
|
+ Assert.Equal(content, actual);
|
|
|
+ templatesBuilt++;
|
|
|
+ return new Border();
|
|
|
+ })
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
[Fact]
|
|
|
public void Should_Not_Propagate_DataContext_To_TabItem_Content()
|
|
|
{
|