Open NGIS72 opened 1 year ago
please provide a minimal sample to reproduce.
Procedure of actions Step 1) Switch to Group A, then click on any two elements Step 2) Switch to Group B, then click on any two elements Step 3) Switch to Group C, then click on any two elements Step 4) Close the window
Not sure why it doesn't work this way, but when I remove unnecessary styles and apply templates directly to the TabControl, it works fine:
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="using:AvaloniaBugApplication1"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="AvaloniaBugApplication1.MainWindow"
Title="AvaloniaBugApplication1">
<TabControl x:Name="Commands"
ItemsSource="{Binding ItemsSource}">
<TabControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Title}" FontWeight="Bold"/>
</DataTemplate>
</TabControl.ItemTemplate>
<TabControl.ContentTemplate>
<DataTemplate>
<ItemsControl ItemsSource="{Binding ItemsSource}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<ToggleButton Content="{Binding Title}" Margin="5" Padding="10"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
</Window>
Makes sense to keep this issue open though
retated to #12753 ?
Not sure why it doesn't work this way, but when I remove unnecessary styles and apply templates directly to the TabControl, it works fine:
<Window xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="using:AvaloniaBugApplication1" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="AvaloniaBugApplication1.MainWindow" Title="AvaloniaBugApplication1"> <TabControl x:Name="Commands" ItemsSource="{Binding ItemsSource}"> <TabControl.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Title}" FontWeight="Bold"/> </DataTemplate> </TabControl.ItemTemplate> <TabControl.ContentTemplate> <DataTemplate> <ItemsControl ItemsSource="{Binding ItemsSource}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <WrapPanel Orientation="Vertical"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <ToggleButton Content="{Binding Title}" Margin="5" Padding="10"/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </DataTemplate> </TabControl.ContentTemplate> </TabControl> </Window>
Makes sense to keep this issue open though
Yes, if you go through the TabControl, then everything works fine. But what if you need to apply the style specifically for TabItem? With an example, everything is clear, but in a real project, this option will most likely not work. In any case, this behavior is not normal when, due to the style, an error occurs when closing the application.
retated to #12753 ?
There is another most likely
Stuck with this bug too. I don't know how much this would helpful. I Turned off "Just my code" during debugging and found this:
Maybe some kind of race condition, don't know, but logicalChildren
collections seems to be changed during enumerating
count
and logicalChildren.Count
are mismatched
Avalonia 11.0.4 internal error after closing the main application window.
Message: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
StackTrace:
at System.ThrowHelper.ThrowArgumentOutOfRange_IndexException() at Avalonia.Collections.AvaloniaList`1.get_Item(Int32 index) at Avalonia.StyledElement.OnDetachedFromLogicalTreeCore(LogicalTreeAttachmentEventArgs e) at Avalonia.StyledElement.OnDetachedFromLogicalTreeCore(LogicalTreeAttachmentEventArgs e) at Avalonia.StyledElement.OnDetachedFromLogicalTreeCore(LogicalTreeAttachmentEventArgs e) at Avalonia.Controls.TopLevel.HandleClosed() at Avalonia.Controls.WindowBase.HandleClosed() at Avalonia.Controls.Window.HandleClosed() at Avalonia.Win32.WindowImpl.AppWndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam) at Avalonia.Win32.WindowImpl.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)