51 lines
2.6 KiB
XML
51 lines
2.6 KiB
XML
<UserControl x:Class="YY.Admin.Views.Control.MenuTreeView"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
xmlns:local="clr-namespace:YY.Admin.Views"
|
|
xmlns:beh="clr-namespace:YY.Admin.Core.Behavior;assembly=YY.Admin.Core"
|
|
mc:Ignorable="d"
|
|
d:DesignHeight="450" d:DesignWidth="800">
|
|
<TreeView
|
|
x:Name="MenuTree"
|
|
ItemsSource="{Binding MenuItems}"
|
|
Background="Transparent"
|
|
BorderThickness="0">
|
|
<TreeView.ItemContainerStyle>
|
|
<Style TargetType="TreeViewItem" BasedOn="{StaticResource CusTreeViewItemBaseStyle}">
|
|
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
|
|
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
|
|
<Setter Property="FontSize" Value="{StaticResource FontSize}"/>
|
|
<Setter Property="Cursor" Value="Hand"/>
|
|
|
|
<!-- 禁止双击自动展开 -->
|
|
<EventSetter Event="MouseDoubleClick" Handler="TreeViewItem_MouseDoubleClick"/>
|
|
<!--<Setter Property="Margin" Value="0"/>-->
|
|
<!-- 绑定命令到 TreeView 的 DataContext 下的 NavigateCommand -->
|
|
<Setter
|
|
Property="beh:TreeViewItemClickBehavior.Command"
|
|
Value="{Binding DataContext.NavigateCommand,
|
|
RelativeSource={RelativeSource AncestorType=TreeView}}"/>
|
|
<!-- 把命令参数设为当前数据上下文(菜单项本身) -->
|
|
<Setter Property="beh:TreeViewItemClickBehavior.CommandParameter" Value="{Binding}"/>
|
|
</Style>
|
|
</TreeView.ItemContainerStyle>
|
|
<TreeView.ItemTemplate>
|
|
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
|
|
<StackPanel Orientation="Horizontal" Height="50">
|
|
<!--菜单图标-->
|
|
<TextBlock
|
|
Text="{Binding Icon}"
|
|
FontFamily="{StaticResource AntDesignIcon}"
|
|
FontSize="16"
|
|
VerticalAlignment="Center"
|
|
Margin="20,0,12,0"/>
|
|
<!--菜单名称-->
|
|
<TextBlock Text="{Binding Name}" VerticalAlignment="Center"/>
|
|
</StackPanel>
|
|
</HierarchicalDataTemplate>
|
|
</TreeView.ItemTemplate>
|
|
</TreeView>
|
|
</UserControl>
|