You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
9.1 KiB
Plaintext

<UserControl x:Class="StartServerWPF.Modules.Main.Views.TreeMenuView"
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:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/StartServerWPF.Assets;component/Styles/BaseResources.xaml"/>
<!--<ResourceDictionary Source="/Detection.platform.Assets;component/Styles/ButtonStyles.xaml"/>-->
<ResourceDictionary>
<ControlTemplate TargetType="ToggleButton" x:Key="ArrowButtonTemplate">
<Grid Background="Transparent" Name="back">
<TextBlock Text="&#xe81d;" FontFamily="{StaticResource Iconfont}"
VerticalAlignment="Center" HorizontalAlignment="Center"
RenderTransformOrigin="0.5,0.5" Name="arrow">
</TextBlock>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="arrow" Property="RenderTransform">
<Setter.Value>
<RotateTransform Angle="90"/>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="back" Property="Background" Value="#11000000"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid Background="#FF262E37">
<Grid.Resources>
<Style TargetType="TreeViewItem">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"></Setter>
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
<Setter Property="KeyboardNavigation.AcceptsReturn" Value="True" />
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="8,5"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontFamily" Value="{StaticResource Iconfont}"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TreeViewItem">
<Grid Background="Transparent" Name="root">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition MaxWidth="30"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" MinHeight="36"/>
<RowDefinition />
</Grid.RowDefinitions>
<Grid.InputBindings>
<MouseBinding MouseAction="LeftDoubleClick"
Command="{Binding OpenViewCommand}"
CommandParameter="{Binding}"/>
</Grid.InputBindings>
<Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
CornerRadius="0" Grid.ColumnSpan="2" Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="true">
<ContentPresenter x:Name="PART_Header" ContentSource="Header"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
</ContentPresenter>
</Border>
<ToggleButton x:Name="Expander" Grid.Column="1" ClickMode="Press"
IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}"
Template="{StaticResource ArrowButtonTemplate}"/>
<ItemsPresenter x:Name="ItemsHost" Margin="18,0,0,0" Grid.ColumnSpan="2" Grid.Row="1" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded" Value="false">
<Setter Property="Visibility" TargetName="ItemsHost" Value="Collapsed"/>
</Trigger>
<Trigger Property="HasItems" Value="false">
<Setter Property="Visibility" TargetName="Expander" Value="Hidden"/>
</Trigger>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Background" TargetName="Bd" Value="#FF009DFF"/>
<Setter Property="Foreground" Value="#FFFFFFFF"/>
<Setter Property="Foreground" Value="#FFFFFFFF" TargetName="Expander"/>
</Trigger>
<!--被选中后失去焦点-->
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="true"/>
<Condition Property="IsSelectionActive" Value="false"/>
</MultiTrigger.Conditions>
<Setter Property="Background" TargetName="Bd" Value="SkyBlue"/>
<Setter Property="Foreground" Value="#FFFFFFFF"/>
</MultiTrigger>
<DataTrigger Binding="{Binding MenuIcon}" Value="{x:Null}">
<Setter Property="Margin" Value="10,0,0,0" TargetName="root"/>
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<TreeView BorderThickness="0" Background="Transparent" ItemsSource="{Binding Menus}" Margin="0,10">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Children,Mode=TwoWay}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30" Name="c1"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding MenuIcon}" VerticalAlignment="Center" HorizontalAlignment="Center"
FontSize="15" SnapsToDevicePixels="True"
FontFamily="{StaticResource Iconfont}"/>
<TextBlock Text="{Binding MenuHeader}" Grid.Column="1" Margin="5,5,0,5" FontSize="15"/>
</Grid>
<HierarchicalDataTemplate.Triggers>
<DataTrigger Binding="{Binding MenuIcon}" Value="{x:Null}">
<Setter TargetName="c1" Property="Width" Value="0"/>
</DataTrigger>
</HierarchicalDataTemplate.Triggers>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
</Grid>
</UserControl>