AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.88k stars 2.24k forks source link

PageTransition broke TabControl dynamic TabItem insert #2051

Closed latop2604 closed 5 years ago

latop2604 commented 6 years ago

I want to dynamically add tab item to a tab control just before the last TabItem. I do it like this. I didn't found a better way to do it. At least like with WPF.

The issue is after the item is added. When I click on a TabItem Name, it took the selected style but the TabControl content is not updated anymore.

Removing PageTransition seem solve the issue.

<!-- I need to remove that to be able to add new TabItem -->
<TabControl.PageTransition>
    <CrossFade Duration="0.25"/>
</TabControl.PageTransition>
var tabItem = new TabItem()
{
    Header = e.Name,
    Content = documentViewer,
};

var items = Tabs.Items.Cast<object>().ToList();
items.Insert(items.Count - 1, tabItem);

Tabs.Items = items;

Tabs.SelectedIndex = items.Count - 1;

Deps

<PackageReference Include="Avalonia" Version="0.7.0-build431-beta" />
<PackageReference Include="Avalonia.Desktop" Version="0.7.0-build431-beta" />
<PackageReference Include="Avalonia.Native" Version="0.7.0-build431-beta" />
Gillibald commented 5 years ago

Pls try the new TabControl #1842

latop2604 commented 5 years ago

PageTransition property seem not available anymore.

Gillibald commented 5 years ago

That was removed yes.

latop2604 commented 5 years ago

Ok so I close this issue as obsolete

KacperChmielowiec commented 1 year ago

Avalonia suck, even insert element is hard to handle.