AvaloniaUI/Avalonia

System.InvalidOperationException when add tabitem to tabcontrol

Jhinxs opened this issue · 1 comments

Describe the bug

if i enable this in App.axaml:

    <FluentTheme DensityStyle="Compact">
        <FluentTheme.Palettes>
            <ColorPaletteResources x:Key="Light" Accent="#BCD2EE" />
        </FluentTheme.Palettes>
    </FluentTheme>

then add tabitem to tabcontrol like this:

public MainWindow()
{
    InitializeComponent();
    EventLogTab myEventLogTab = new EventLogTab();
    this.mytabcontrol.Items.Add(myEventLogTab);
   
}

will throw an exception like this :

System.InvalidOperationException: The control Grid already has a visual parent ContentPresenter (Name = PART_SelectedContentHost, Host = TabControl (Name = RBRMainTab)) while trying to add it as a child of ContentPresenter (Name = PART_ContentPresenter, Host = AvaloniaApplication.EventLogTab).

image

my tabitem style:

image

To Reproduce

1

Expected behavior

1

Avalonia version

11.2.2.

OS

Windows

Additional context

No response

and i try again, if add use FluentTheme will trigger exception