You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have found a feasible solution by adding the following recursive method to NavigationViewItem. cs:
private void ClearActiveStatus(IList menuitems, NavigationView navigationView)
{
foreach (var item in menuitems)
{
var nvaitem = item as NavigationViewItem;
if (nvaitem != null)
{
if (nvaitem.IsActive)
{
nvaitem.Deactivate(navigationView);
}
if (nvaitem.HasMenuItems)
{
ClearActiveStatus(nvaitem.MenuItems, navigationView);
}
}
}
}
Then call within Onclick:
var navigation = NavigationView.GetNavigationParent(this);
if (navigation is not null)
{
IList menuitems = navigation.MenuItems;
ClearActiveStatus(menuitems, navigation);
Activate(navigation);
}
The complete modification code is:
protected override void OnClick()
{
if (NavigationView.GetNavigationParent(this) is not { } navigationView)
{
return;
}
var navigation = NavigationView.GetNavigationParent(this);
if (navigation is not null)
{
IList menuitems = navigation.MenuItems;
ClearActiveStatus(menuitems, navigation);
Activate(navigation);
}
if (HasMenuItems && navigationView.IsPaneOpen)
{
SetCurrentValue(IsExpandedProperty, !IsExpanded);
}
if (TargetPageType is not null)
{
navigationView.OnNavigationViewItemClick(this);
}
base.OnClick();
}
private void ClearActiveStatus(IList menuitems, NavigationView navigationView)
{
foreach (var item in menuitems)
{
var navitem = item as NavigationViewItem;
if (navitem != null)
{
if (navitem.IsActive)
{
navitem.Deactivate(navigationView);
}
if (navitem.HasMenuItems)
{
ClearActiveStatus(navitem.MenuItems, navigationView);
}
}
}
}
✌
🚀Someone can help review this code for any issues, and it would be even better if they could also assist in submitting the merge.😀
Describe the bug
the TargetPageType attribute. When deleting the TargetPageType attribute or leaving it null,
there will be an error in displaying the selected style
To Reproduce
When deleting the TargetPageType attribute or leaving it null, there will be an error in displaying the selected style。
Expected behavior
This issue occurs when the NavigationViewItem does not have the TargetPageType property set. Inference and IsActive trigger xaml style incorrect
Screenshots
error:
success:
OS version
win11
.NET version
.net8
WPF-UI NuGet version
3.0.4
Additional context
No response
The text was updated successfully, but these errors were encountered: