-
Notifications
You must be signed in to change notification settings - Fork 717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GTK Linux] NavigationView
- Can't remove NavigationViewItem
#8584
Comments
Thanks for the report. Could you create a small repro app which shows the issue, so we can discuss the exact same behavior? |
Send you link to small app to show the issue: https://github.com/OnSwitchOff/MyUnoAppSer.git. The issue is in PageClose method (MainPage). I've added TextBox, DatePicker and CalendarDatePicker due to behaviour of them on Linux:
|
NavigationView
- Can't remove NavigationViewItem
Minimized repro: XAML: <NavigationView x:Name="navigationView" IsBackButtonVisible="Collapsed" IsBackEnabled="False">
<NavigationView.MenuItems>
<NavigationViewItem Content="Sale" />
<NavigationViewItemSeparator/>
<NavigationViewItemHeader Content="Sales"/>
</NavigationView.MenuItems>
</NavigationView> Code behind: public sealed partial class MainPage : Page
{
private int count = 0;
public MainPage()
{
this.InitializeComponent();
this.navigationView.ItemInvoked += this.NavigationView_ItemInvoked;
}
private void NavigationView_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
{
NavigationViewItem saleItem = new NavigationViewItem() { IsSelected = true };
this.navigationView.MenuItems.Add(saleItem);
this.navigationView.SelectedItem = saleItem;
if (++count == 2)
{
PageClose(this.navigationView.MenuItems.Last() as NavigationViewItem);
PageClose(this.navigationView.MenuItems.Last() as NavigationViewItem);
}
}
private void PageClose(NavigationViewItem item)
{
this.navigationView.MenuItems.Remove(item);
this.navigationView.SelectedItem = this.navigationView.MenuItems.Last();
}
} IMPORTANT: This is only reproducible with MUXC version of NavigationView. So, for testing in samples app, make sure to include |
Use this commit for easier debugging in Uno. |
It's getting tricky to understand what is going on. One important observation is
However, even if I try to give up using the cache and instead get the count directly, the code still crashes, but happens at a later point with different stack trace. |
Here is why the count cache was out of sync. There are (at least) two instances of ItemsSourceView that are operating on the SAME observable collection.
The stack trace is large so split into two screenshots:
|
In the above stack trace, there is a measure happening which DOES NOT happen in WinUI. |
Current behavior
I create new pages and dynamically (from the code behind) add the NavigationViewItem corresponding to this page. When the page is closed by the user (the "X" button placed on the page), the previously added NavigationViewItem is also removed. The first closing of the page and removal of the NavigationViewItem is successful. All subsequent attempts lead to the following situation: NavigationViewItem is removed from MenuItems with the next error
It works correctly on Windows, but makes a mistake on Linux!
Expected behavior
NavigationViewItem is removed successfully (without errors) from the MenuItems of NavigationView
How to reproduce it (as minimally and precisely as possible)
Workaround
No response
Works on UWP/WinUI
Yes
Environment
No response
NuGet package version(s)
Uno.CommunityToolkit.WinUI.UI.Behaviors" Version="7.1.100-dev.7.g758154cb81"
Uno.Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.3.0"
Uno.WinUI.Skia.Gtk" Version="4.1.9"
Uno.WinUI.RemoteControl" Version="4.1.9" Condition="'$(Configuration)'=='Debug'"
Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.1.9"
Uno.CommunityToolkit.WinUI.UI.Controls.DataGrid" Version="7.1.100-dev.7.g758154cb81"
Uno.CommunityToolkit.WinUI.UI.Controls.Layout" Version="7.1.100-dev.7.g758154cb81"
Affected platforms
Skia (GTK on Linux/macOS/Windows)
IDE
Visual Studio 2022
IDE version
No response
Relevant plugins
No response
Anything else we need to know?
I use Rider to run my app on Linux.
The text was updated successfully, but these errors were encountered: