mirror of
https://gitee.com/handyorg/HandyControl.git
synced 2024-12-02 03:47:48 +08:00
completed the branch
This commit is contained in:
parent
bb27ef7635
commit
a7544f6171
@ -48,6 +48,10 @@ Step 3:enjoy coding
|
||||
|
||||
## Latest examples
|
||||
|
||||
### SideMenu
|
||||
|
||||
![SideMenu](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/SideMenu.png)
|
||||
|
||||
### NotifyIcon
|
||||
|
||||
![NotifyIcon](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/NotifyIcon.png)
|
||||
@ -64,12 +68,12 @@ Step 3:enjoy coding
|
||||
|
||||
![Badge](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/Badge.png)
|
||||
|
||||
## History publication
|
||||
|
||||
### Gravatar
|
||||
|
||||
![Gravatar](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/Gravatar.gif)
|
||||
|
||||
## History publication
|
||||
|
||||
### GoToTop
|
||||
|
||||
![GoToTop](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/GoToTop.gif)
|
||||
|
BIN
Resources/SideMenu.png
Normal file
BIN
Resources/SideMenu.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
@ -321,6 +321,30 @@
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\under_construction.gif">
|
||||
<Link>Resources\Img\under_construction.gif</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\DevOps\DevOps-Boards.png">
|
||||
<Link>Resources\Img\DevOps\DevOps-Boards.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\DevOps\DevOps-Overview.png">
|
||||
<Link>Resources\Img\DevOps\DevOps-Overview.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\DevOps\DevOps-Pipelines.png">
|
||||
<Link>Resources\Img\DevOps\DevOps-Pipelines.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\DevOps\DevOps-Repos.png">
|
||||
<Link>Resources\Img\DevOps\DevOps-Repos.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\DevOps\DevOps-TestPlans.png">
|
||||
<Link>Resources\Img\DevOps\DevOps-TestPlans.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\MainMenuControl_16x.png">
|
||||
<Link>Resources\Img\LeftMainContent\MainMenuControl_16x.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\fabric-icons.ttf">
|
||||
<Link>Resources\fabric-icons.ttf</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\MainMenuControl_16x.png">
|
||||
<Link>Resources\Img\LeftMainContent\MainMenuControl_16x.png</Link>
|
||||
</Resource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\..\Shared\HandyControlDemo_Shared\Properties\Langs\Lang.en.resx">
|
||||
|
@ -381,13 +381,35 @@
|
||||
<LastGenOutput>Lang.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\fabric-icons.ttf">
|
||||
<Link>Resources\fabric-icons.ttf</Link>
|
||||
</Resource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="..\..\Shared\HandyControlDemo_Shared\Data\MessageToken.tt">
|
||||
<Link>Data\MessageToken.tt</Link>
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>MessageToken.cs</LastGenOutput>
|
||||
</Content>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\MainMenuControl_16x.png">
|
||||
<Link>Resources\Img\LeftMainContent\MainMenuControl_16x.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\DevOps\DevOps-Boards.png">
|
||||
<Link>Resources\Img\DevOps\DevOps-Boards.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\DevOps\DevOps-Overview.png">
|
||||
<Link>Resources\Img\DevOps\DevOps-Overview.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\DevOps\DevOps-Pipelines.png">
|
||||
<Link>Resources\Img\DevOps\DevOps-Pipelines.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\DevOps\DevOps-Repos.png">
|
||||
<Link>Resources\Img\DevOps\DevOps-Repos.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\DevOps\DevOps-TestPlans.png">
|
||||
<Link>Resources\Img\DevOps\DevOps-TestPlans.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\RepeatButton_16x.png">
|
||||
<Link>Resources\Img\LeftMainContent\RepeatButton_16x.png</Link>
|
||||
</Resource>
|
||||
|
@ -283,6 +283,7 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\NotifyIconDemoViewModel.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\PaginationDemoViewModel.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\SearchBarDemoViewModel.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\SideMenuDemoViewModel.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\StepBarDemoViewModel.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\WindowDemoViewModel.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\DemoViewModelBase!1.cs" />
|
||||
|
@ -2,11 +2,18 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
|
||||
xmlns:interactivity="clr-namespace:HandyControl.Interactivity;assembly=HandyControl"
|
||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
xmlns:command="http://www.galasoft.ch/mvvmlight"
|
||||
DataContext="{Binding SideMenuDemo,Source={StaticResource Locator}}"
|
||||
Background="{DynamicResource RegionBrush}">
|
||||
|
||||
<Grid>
|
||||
<controls:SideMenu ExpandMode="ShowOne" BorderThickness="1" Width="200" Margin="32">
|
||||
<controls:TransitioningContentControl>
|
||||
<controls:SideMenu BorderThickness="1" Width="200" Margin="32">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="SelectionChanged">
|
||||
<command:EventToCommand Command="{Binding SwitchItemCmd}" PassEventArgsToCommand="True" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
<controls:SideMenuItem Header="Overview">
|
||||
<controls:SideMenuItem.Icon>
|
||||
<Image Source="/HandyControlDemo;component/Resources/Img/DevOps/DevOps-Overview.png" Width="24" Height="24"/>
|
||||
@ -143,6 +150,6 @@
|
||||
</controls:SideMenuItem>
|
||||
</controls:SideMenuItem>
|
||||
</controls:SideMenu>
|
||||
</Grid>
|
||||
</controls:TransitioningContentControl>
|
||||
|
||||
</UserControl>
|
||||
|
@ -203,7 +203,7 @@
|
||||
<Image Source="../../Resources/Img/LeftMainContent/DotLarge_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.GotoTopDemoCtl}" Content="{x:Static langs:Lang.GotoTop}">
|
||||
<ListBoxItem Tag="{x:Static data:MessageToken.GotoTopDemoCtl}" Content="{x:Static langs:Lang.GotoTop}">
|
||||
<controls:EdgeElement.LeftContent>
|
||||
<Image Source="../../Resources/Img/LeftMainContent/GoToTop_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using GalaSoft.MvvmLight;
|
||||
using HandyControl.Controls;
|
||||
using HandyControl.Data;
|
||||
#if netle40
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
#else
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
# endif
|
||||
|
||||
namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
public class SideMenuDemoViewModel : ViewModelBase
|
||||
{
|
||||
public RelayCommand<FunctionEventArgs<object>> SwitchItemCmd => new Lazy<RelayCommand<FunctionEventArgs<object>>>(() =>
|
||||
new RelayCommand<FunctionEventArgs<object>>(SwitchItem)).Value;
|
||||
|
||||
private void SwitchItem(FunctionEventArgs<object> info) => Growl.Info((info.Info as SideMenuItem)?.Header.ToString());
|
||||
}
|
||||
}
|
@ -33,6 +33,7 @@ namespace HandyControlDemo.ViewModel
|
||||
SimpleIoc.Default.Register<NotifyIconDemoViewModel>();
|
||||
SimpleIoc.Default.Register<InteractiveDialogViewModel>();
|
||||
SimpleIoc.Default.Register<BadgeDemoViewModel>();
|
||||
SimpleIoc.Default.Register<SideMenuDemoViewModel>();
|
||||
}
|
||||
|
||||
public static ViewModelLocator Instance => new Lazy<ViewModelLocator>(() =>
|
||||
@ -71,6 +72,9 @@ namespace HandyControlDemo.ViewModel
|
||||
public InteractiveDialogViewModel InteractiveDialog => ServiceLocator.Current.GetInstance<InteractiveDialogViewModel>();
|
||||
|
||||
public BadgeDemoViewModel BadgeDemo => ServiceLocator.Current.GetInstance<BadgeDemoViewModel>();
|
||||
|
||||
public SideMenuDemoViewModel SideMenuDemo => ServiceLocator.Current.GetInstance<SideMenuDemoViewModel>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using System.Windows;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Data.Enum;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
@ -15,6 +16,22 @@ namespace HandyControl.Controls
|
||||
public SideMenu()
|
||||
{
|
||||
AddHandler(SideMenuItem.SelectedEvent, new RoutedEventHandler(SideMenuItemSelected));
|
||||
|
||||
Loaded += (s, e) => Init();
|
||||
}
|
||||
|
||||
protected override void Refresh()
|
||||
{
|
||||
base.Refresh();
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
if (ItemsHost == null) return;
|
||||
|
||||
OnExpandModeChanged(ExpandMode);
|
||||
}
|
||||
|
||||
private void SideMenuItemSelected(object sender, RoutedEventArgs e)
|
||||
@ -23,6 +40,8 @@ namespace HandyControl.Controls
|
||||
{
|
||||
if (item.Role == SideMenuItemRole.Item)
|
||||
{
|
||||
if (Equals(item, _selectedItem)) return;
|
||||
|
||||
if (_selectedItem != null)
|
||||
{
|
||||
_selectedItem.IsSelected = false;
|
||||
@ -30,6 +49,10 @@ namespace HandyControl.Controls
|
||||
|
||||
_selectedItem = item;
|
||||
_selectedItem.IsSelected = true;
|
||||
RaiseEvent(new FunctionEventArgs<object>(SelectionChangedEvent, this)
|
||||
{
|
||||
Info = e.OriginalSource
|
||||
});
|
||||
_isItemSelected = true;
|
||||
}
|
||||
else
|
||||
@ -38,20 +61,36 @@ namespace HandyControl.Controls
|
||||
{
|
||||
if (_selectedHeader != null)
|
||||
{
|
||||
if (ExpandMode == ExpandMode.Freedom && item.ItemsHost.IsVisible && !_isItemSelected)
|
||||
{
|
||||
item.IsSelected = false;
|
||||
SwitchPanelArea(item);
|
||||
return;
|
||||
}
|
||||
|
||||
_selectedHeader.IsSelected = false;
|
||||
SwitchPanelArea(_selectedHeader);
|
||||
if (ExpandMode != ExpandMode.Freedom)
|
||||
{
|
||||
SwitchPanelArea(_selectedHeader);
|
||||
}
|
||||
}
|
||||
|
||||
_selectedHeader = item;
|
||||
_selectedHeader.IsSelected = true;
|
||||
SwitchPanelArea(_selectedHeader);
|
||||
}
|
||||
else if (ExpandMode == ExpandMode.Freedom && !_isItemSelected)
|
||||
{
|
||||
_selectedHeader.IsSelected = false;
|
||||
SwitchPanelArea(_selectedHeader);
|
||||
_selectedHeader = null;
|
||||
}
|
||||
|
||||
if (_isItemSelected)
|
||||
{
|
||||
_isItemSelected = false;
|
||||
}
|
||||
else
|
||||
else if(_selectedHeader != null)
|
||||
{
|
||||
_selectedHeader.SelectDefaultItem();
|
||||
_isItemSelected = false;
|
||||
@ -67,6 +106,7 @@ namespace HandyControl.Controls
|
||||
case ExpandMode.ShowAll:
|
||||
return;
|
||||
case ExpandMode.ShowOne:
|
||||
case ExpandMode.Freedom:
|
||||
case ExpandMode.Accordion:
|
||||
oldItem.SwitchPanelArea(oldItem.IsSelected);
|
||||
break;
|
||||
@ -78,12 +118,72 @@ namespace HandyControl.Controls
|
||||
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)));
|
||||
"ExpandMode", typeof(ExpandMode), typeof(SideMenu), new PropertyMetadata(default(ExpandMode), OnExpandModeChanged));
|
||||
|
||||
private static void OnExpandModeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var ctl = (SideMenu) d;
|
||||
var v = (ExpandMode) e.NewValue;
|
||||
|
||||
if (ctl.ItemsHost == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ctl.OnExpandModeChanged(v);
|
||||
}
|
||||
|
||||
private void OnExpandModeChanged(ExpandMode mode)
|
||||
{
|
||||
if (mode == ExpandMode.ShowAll)
|
||||
{
|
||||
ShowAll();
|
||||
}
|
||||
else if (mode == ExpandMode.ShowOne)
|
||||
{
|
||||
var sideMenuItem = ItemsHost.Children.OfType<SideMenuItem>().FirstOrDefault(item => item.IsSelected);
|
||||
ShowSelectedOne(sideMenuItem);
|
||||
}
|
||||
}
|
||||
|
||||
public ExpandMode ExpandMode
|
||||
{
|
||||
get => (ExpandMode) GetValue(ExpandModeProperty);
|
||||
set => SetValue(ExpandModeProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty PanelAreaLengthProperty = DependencyProperty.Register(
|
||||
"PanelAreaLength", typeof(double), typeof(SideMenu), new PropertyMetadata(double.NaN));
|
||||
|
||||
public double PanelAreaLength
|
||||
{
|
||||
get => (double) GetValue(PanelAreaLengthProperty);
|
||||
set => SetValue(PanelAreaLengthProperty, value);
|
||||
}
|
||||
|
||||
private void ShowAll()
|
||||
{
|
||||
foreach (var sideMenuItem in ItemsHost.Children.OfType<SideMenuItem>())
|
||||
{
|
||||
sideMenuItem.SwitchPanelArea(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowSelectedOne(SideMenuItem item)
|
||||
{
|
||||
foreach (var sideMenuItem in ItemsHost.Children.OfType<SideMenuItem>())
|
||||
{
|
||||
sideMenuItem.SwitchPanelArea(Equals(sideMenuItem, item));
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly RoutedEvent SelectionChangedEvent = EventManager.RegisterRoutedEvent(
|
||||
"SelectionChanged", RoutingStrategy.Bubble, typeof(EventHandler<FunctionEventArgs<object>>), typeof(SideMenu));
|
||||
|
||||
public event EventHandler<FunctionEventArgs<object>> SelectionChanged
|
||||
{
|
||||
add => AddHandler(SelectionChangedEvent, value);
|
||||
remove => RemoveHandler(SelectionChangedEvent, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Tools.Extension;
|
||||
@ -19,6 +20,54 @@ namespace HandyControl.Controls
|
||||
set => SetValue(IconProperty, value);
|
||||
}
|
||||
|
||||
public SideMenuItem()
|
||||
{
|
||||
SetBinding(ExpandModeProperty, new Binding(SideMenu.ExpandModeProperty.Name)
|
||||
{
|
||||
RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(SideMenu), 1)
|
||||
});
|
||||
}
|
||||
|
||||
internal static readonly DependencyProperty ExpandModeProperty =
|
||||
SideMenu.ExpandModeProperty.AddOwner(typeof(SideMenuItem), new PropertyMetadata(default(ExpandMode)));
|
||||
|
||||
internal ExpandMode ExpandMode
|
||||
{
|
||||
get => (ExpandMode) GetValue(ExpandModeProperty);
|
||||
set => SetValue(ExpandModeProperty, value);
|
||||
}
|
||||
|
||||
protected override void Refresh()
|
||||
{
|
||||
if (ItemsHost == null) return;
|
||||
|
||||
ItemsHost.Children.Clear();
|
||||
foreach (var item in Items)
|
||||
{
|
||||
DependencyObject container;
|
||||
if (IsItemItsOwnContainerOverride(item))
|
||||
{
|
||||
container = item as DependencyObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
container = GetContainerForItemOverride();
|
||||
PrepareContainerForItemOverride(container, item);
|
||||
}
|
||||
|
||||
if (container is FrameworkElement element)
|
||||
{
|
||||
element.Style = ItemContainerStyle;
|
||||
ItemsHost.Children.Add(element);
|
||||
}
|
||||
}
|
||||
|
||||
if (IsLoaded)
|
||||
{
|
||||
SwitchPanelArea(ExpandMode == ExpandMode.ShowAll || IsSelected);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnSelected(RoutedEventArgs e) => RaiseEvent(e);
|
||||
|
||||
public static readonly RoutedEvent SelectedEvent =
|
||||
@ -91,11 +140,12 @@ namespace HandyControl.Controls
|
||||
}
|
||||
}
|
||||
|
||||
internal void SwitchPanelArea(bool close)
|
||||
internal void SwitchPanelArea(bool isShow)
|
||||
{
|
||||
if (ItemsHost == null) return;
|
||||
if (Role == SideMenuItemRole.Header)
|
||||
{
|
||||
ItemsHost.Show(close);
|
||||
ItemsHost.Show(isShow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
namespace HandyControl.Data.Enum
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
public enum ExpandMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 显示所有项,且不可折叠
|
||||
/// </summary>
|
||||
ShowAll,
|
||||
|
||||
/// <summary>
|
||||
/// 最多只能显示一项,且不可折叠
|
||||
/// </summary>
|
||||
ShowOne,
|
||||
|
||||
/// <summary>
|
||||
/// 显示所有项,且不可折叠
|
||||
/// </summary>
|
||||
ShowAll,
|
||||
|
||||
/// <summary>
|
||||
/// 类似ShowOne,但是控件的尺寸不随项的数量而改变
|
||||
/// </summary>
|
||||
|
@ -44,6 +44,44 @@
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SideMenuItemAccordionBaseStyle" BasedOn="{StaticResource SideMenuItemBaseStyle}" TargetType="controls:SideMenuItem">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls:SideMenuItem">
|
||||
<Border Name="BorderRoot" Background="{TemplateBinding Background}">
|
||||
<controls:SimplePanel>
|
||||
<Rectangle Width="4" Fill="{TemplateBinding BorderBrush}" HorizontalAlignment="Left"/>
|
||||
<ContentControl Margin="4,0,0,0">
|
||||
<DockPanel Margin="{TemplateBinding Padding}">
|
||||
<ContentControl Width="40" Name="PresenterIcon">
|
||||
<ContentPresenter ContentSource="Icon" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</ContentControl>
|
||||
<ContentPresenter Name="PresenterHeader" ContentSource="Header" Margin="6,0,0,0" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
|
||||
</DockPanel>
|
||||
</ContentControl>
|
||||
</controls:SimplePanel>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="Icon" Value="{x:Null}">
|
||||
<Setter TargetName="PresenterIcon" Property="Visibility" Value="Collapsed"/>
|
||||
</Trigger>
|
||||
<DataTrigger Binding="{Binding IsSelected,RelativeSource={RelativeSource AncestorType=controls:SideMenuItem}}" Value="True">
|
||||
<Setter Property="BorderBrush" Value="Transparent"/>
|
||||
</DataTrigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||
<Setter Property="TextElement.FontWeight" Value="Bold" TargetName="PresenterHeader"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="true">
|
||||
<Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SideMenuItemHeaderBaseStyle" TargetType="controls:SideMenuItem">
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
|
||||
@ -66,7 +104,50 @@
|
||||
<ContentPresenter Name="PresenterHeader" ContentSource="Header" Margin="6,0,0,0" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
|
||||
</DockPanel>
|
||||
</ContentControl>
|
||||
<StackPanel Grid.Row="1" x:Name="PART_Panel"/>
|
||||
<StackPanel Grid.Row="1" x:Name="PART_Panel" Visibility="Collapsed" Height="{Binding PanelAreaLength,RelativeSource={RelativeSource AncestorType=controls:SideMenu}}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="Icon" Value="{x:Null}">
|
||||
<Setter TargetName="PresenterIcon" Property="Visibility" Value="Collapsed"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter TargetName="BorderBack" Property="BorderThickness" Value="4,0,0,0"/>
|
||||
<Setter TargetName="BorderBack" Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
|
||||
<Setter Property="TextElement.FontWeight" Value="Bold" TargetName="PresenterHeader"/>
|
||||
</Trigger>
|
||||
<Trigger SourceName="PanelHeader" Property="IsMouseOver" Value="true">
|
||||
<Setter TargetName="BorderBack" Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SideMenuItemHeaderAccordionBaseStyle" BasedOn="{StaticResource SideMenuItemHeaderBaseStyle}" TargetType="controls:SideMenuItem">
|
||||
<Setter Property="ItemContainerStyle" Value="{StaticResource SideMenuItemAccordionBaseStyle}"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls:SideMenuItem">
|
||||
<Border Name="BorderRoot" Background="{TemplateBinding Background}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition MinHeight="48"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Border Name="BorderBack" Background="{TemplateBinding Background}"/>
|
||||
<ContentControl Grid.Row="0" Margin="4,0,0,0">
|
||||
<DockPanel Margin="{TemplateBinding Padding}" Name="PanelHeader" Background="Transparent">
|
||||
<ContentControl Width="40" Name="PresenterIcon">
|
||||
<ContentPresenter ContentSource="Icon" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</ContentControl>
|
||||
<ContentPresenter Name="PresenterHeader" ContentSource="Header" Margin="6,0,0,0" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
|
||||
</DockPanel>
|
||||
</ContentControl>
|
||||
<ScrollViewer Visibility="{Binding Visibility,ElementName=PART_Panel}" Grid.Row="1" Height="{Binding PanelAreaLength,RelativeSource={RelativeSource AncestorType=controls:SideMenu}}">
|
||||
<StackPanel x:Name="PART_Panel" Visibility="Collapsed"/>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
|
@ -1,12 +1,26 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Base/SideMenuBaseStyle.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style BasedOn="{StaticResource SideMenuBaseStyle}" TargetType="controls:SideMenu">
|
||||
<Style BasedOn="{StaticResource SideMenuBaseStyle}" TargetType="controls:SideMenu"/>
|
||||
|
||||
<Style x:Key="SideMenuAccordion" BasedOn="{StaticResource SideMenuBaseStyle}" TargetType="controls:SideMenu">
|
||||
<Setter Property="ExpandMode" Value="Accordion"/>
|
||||
<Setter Property="PanelAreaLength" Value="200"/>
|
||||
<Setter Property="ItemContainerStyle" Value="{StaticResource SideMenuItemHeaderAccordionBaseStyle}"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls:SideMenu">
|
||||
<Border Name="BorderRoot" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
|
||||
<StackPanel x:Name="PART_Panel"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
|
@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
#if !netle40
|
||||
using System.Runtime.CompilerServices;
|
||||
#endif
|
||||
using System.Windows;
|
||||
using System.Windows.Markup;
|
||||
using HandyControl.Controls;
|
||||
@ -28,7 +30,7 @@ namespace HandyControl.Tools
|
||||
if (!_lang.IetfLanguageTag.Equals(value.IetfLanguageTag))
|
||||
{
|
||||
_lang = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(Lang));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -52,9 +54,16 @@ namespace HandyControl.Tools
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
#if netle40
|
||||
protected virtual void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
#else
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user