<UserControl x:Class="WPFProject.Controls.MainTabControl"
|
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:WPFProject.Controls"
|
mc:Ignorable="d"
|
d:DesignHeight="450" d:DesignWidth="800">
|
<UserControl.Resources>
|
<ResourceDictionary>
|
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary Source="/HMI.UI;component/Style/Colors.xaml"/>
|
</ResourceDictionary.MergedDictionaries>
|
|
<Style TargetType="ListBox" x:Key="ListBoxItemStyle1">
|
<Setter Property="Background" Value="{StaticResource PrimaryColor}"/>
|
<Setter Property="ItemContainerStyle">
|
<Setter.Value>
|
<Style TargetType="ListBoxItem">
|
<Setter Property="Margin" Value="0"/>
|
<Setter Property="Padding" Value="0"/>
|
<Setter Property="Foreground" Value="{StaticResource PrimaryColorContract}"/>
|
<Setter Property="Template">
|
<Setter.Value>
|
<ControlTemplate TargetType="ListBoxItem">
|
<Border x:Name="border" Background="{StaticResource PrimaryColor}"
|
Padding="10" Margin="0" BorderThickness="0,0,1,1"
|
BorderBrush="Gray">
|
<!-- 内容呈现器 -->
|
<StackPanel>
|
<ContentPresenter x:Name="cp" Content="{TemplateBinding Content}"
|
ContentStringFormat="{TemplateBinding ContentStringFormat}"
|
ContentTemplate="{TemplateBinding ContentTemplate}" />
|
</StackPanel>
|
</Border>
|
|
<ControlTemplate.Triggers>
|
<Trigger Property="IsSelected" Value="True">
|
<Setter TargetName="border" Property="Background"
|
Value="{StaticResource WorkspaceBackground}"/>
|
<Setter Property="Foreground" Value="{StaticResource PrimaryColor}"/>
|
<Setter TargetName="border" Property="BorderThickness" Value="0,0,0,0"/>
|
</Trigger>
|
|
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=Self}, Path=(ItemsControl.AlternationIndex)}" Value="0">
|
<Setter TargetName="border" Property="BorderThickness" Value="1,0,1,0" />
|
</DataTrigger>
|
|
<Trigger Property="IsMouseOver" Value="True">
|
<Setter TargetName="border" Property="Background" Value="{StaticResource SecondPrimaryColor}" />
|
<Setter Property="Foreground" Value="{StaticResource SecondPrimaryColorContract}" />
|
</Trigger>
|
</ControlTemplate.Triggers>
|
</ControlTemplate>
|
</Setter.Value>
|
</Setter>
|
</Style>
|
</Setter.Value>
|
</Setter>
|
<Setter Property="ItemsPanel">
|
<Setter.Value>
|
<ItemsPanelTemplate>
|
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal"/>
|
</ItemsPanelTemplate>
|
</Setter.Value>
|
</Setter>
|
<Setter Property="ItemTemplate">
|
<Setter.Value>
|
<DataTemplate>
|
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" >
|
<Image Width="20" Height="20" Margin="5" Source="{Binding Icon}"/>
|
<Label x:Name="txt" BorderThickness="0"
|
Foreground="{Binding Foreground,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ListBoxItem}}"
|
FontWeight="Bold"
|
FontSize="16"
|
VerticalContentAlignment="Center"
|
HorizontalAlignment="Left"
|
Content="{Binding Name}" ToolTip="{Binding Name}"/>
|
</StackPanel>
|
</DataTemplate>
|
</Setter.Value>
|
</Setter>
|
</Style>
|
</ResourceDictionary>
|
</UserControl.Resources>
|
|
<Grid x:Name="mainGrid">
|
<Grid.RowDefinitions>
|
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
<RowDefinition/>
|
</Grid.RowDefinitions>
|
|
<ListBox Grid.Row="0" x:Name="Menu" Margin="0" Padding="-1"
|
Style="{StaticResource ListBoxItemStyle1}"
|
BorderBrush="Gray"
|
BorderThickness="0,1,0,1"
|
Visibility="{Binding MenuVisibility}"
|
SelectionChanged="Menu_SelectionChanged"
|
SelectedItem="{Binding SelectedMenu}"
|
AlternationCount="{Binding MenuItemsCount}" ItemsSource="{Binding MenuItems}">
|
|
</ListBox>
|
|
<ListBox Grid.Row="1" x:Name="SubMenu" Margin="0" Padding="-1"
|
Style="{StaticResource ListBoxItemStyle1}"
|
BorderBrush="Gray"
|
Visibility="{Binding MenuVisibility}"
|
SelectedItem="{Binding SelectedSubMenu}" AlternationCount="{Binding SubMenuItemsCount}"
|
SelectionChanged="SubMenu_SelectionChanged"
|
BorderThickness="0" ItemsSource="{Binding SubMenuItems}">
|
</ListBox>
|
|
<Border x:Name="page" Grid.Row="2" BorderThickness="0" Margin="0" Padding="0">
|
|
</Border>
|
</Grid>
|
</UserControl>
|