diff --git a/src/Shared/HandyControl_Shared/Controls/SideMenu/SideMenu.cs b/src/Shared/HandyControl_Shared/Controls/SideMenu/SideMenu.cs index 21a2e572..5433e4a3 100644 --- a/src/Shared/HandyControl_Shared/Controls/SideMenu/SideMenu.cs +++ b/src/Shared/HandyControl_Shared/Controls/SideMenu/SideMenu.cs @@ -40,6 +40,8 @@ namespace HandyControl.Controls { if (item.Role == SideMenuItemRole.Item) { + _isItemSelected = true; + if (Equals(item, _selectedItem)) return; if (_selectedItem != null) @@ -53,7 +55,6 @@ namespace HandyControl.Controls { Info = e.OriginalSource }); - _isItemSelected = true; } else { @@ -92,7 +93,10 @@ namespace HandyControl.Controls } else if(_selectedHeader != null) { - _selectedHeader.SelectDefaultItem(); + if (AutoSelect) + { + _selectedHeader.SelectDefaultItem(); + } _isItemSelected = false; } } @@ -117,6 +121,15 @@ namespace HandyControl.Controls protected override bool IsItemItsOwnContainerOverride(object item) => item is SideMenuItem; + public static readonly DependencyProperty AutoSelectProperty = DependencyProperty.Register( + "AutoSelect", typeof(bool), typeof(SideMenu), new PropertyMetadata(ValueBoxes.TrueBox)); + + public bool AutoSelect + { + get => (bool) GetValue(AutoSelectProperty); + set => SetValue(AutoSelectProperty, value); + } + public static readonly DependencyProperty ExpandModeProperty = DependencyProperty.Register( "ExpandMode", typeof(ExpandMode), typeof(SideMenu), new PropertyMetadata(default(ExpandMode), OnExpandModeChanged));