add expandmode property step1

This commit is contained in:
NaBian committed 2019-05-04 15:10:15 +08:00
1 parent 145c47711f
commit bb27ef7635
3 files changed
+35 -1

No files matched your search

@@ -1,5 +1,6 @@
using System.Windows;
using HandyControl.Data;
using HandyControl.Data.Enum;
namespace HandyControl.Controls
{
@@ -38,10 +39,12 @@ namespace HandyControl.Controls
if (_selectedHeader != null)
{
_selectedHeader.IsSelected = false;
SwitchPanelArea(_selectedHeader);
}
_selectedHeader = item;
_selectedHeader.IsSelected = true;
SwitchPanelArea(_selectedHeader);
}
if (_isItemSelected)
@@ -57,8 +60,30 @@ namespace HandyControl.Controls
}
}
private void SwitchPanelArea(SideMenuItem oldItem)
{
switch (ExpandMode)
{
case ExpandMode.ShowAll:
return;
case ExpandMode.ShowOne:
case ExpandMode.Accordion:
oldItem.SwitchPanelArea(oldItem.IsSelected);
break;
}
}
protected override DependencyObject GetContainerForItemOverride() => new SideMenuItem();
protected override bool IsItemItsOwnContainerOverride(object item) => item is SideMenuItem;
public static readonly DependencyProperty ExpandModeProperty = DependencyProperty.Register(
"ExpandMode", typeof(ExpandMode), typeof(SideMenu), new PropertyMetadata(default(ExpandMode)));
public ExpandMode ExpandMode
{
get => (ExpandMode) GetValue(ExpandModeProperty);
set => SetValue(ExpandModeProperty, value);
}
}
}
@@ -2,6 +2,7 @@
using System.Windows;
using System.Windows.Input;
using HandyControl.Data;
using HandyControl.Tools.Extension;
namespace HandyControl.Controls
{
@@ -89,5 +90,13 @@ namespace HandyControl.Controls
}
}
}
internal void SwitchPanelArea(bool close)
{
if (Role == SideMenuItemRole.Header)
{
ItemsHost.Show(close);
}
}
}
}