<Window x:Class="MainShell.ToolBox.View.ToolBoxWindowView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:MainShell.ToolBox.View" 
        xmlns:vm="clr-namespace:MainShell.Models"
        xmlns:toolvm="clr-namespace:MainShell.ToolBox.ViewModel"
        AllowsTransparency="False"
        WindowStyle="None"
      
        mc:Ignorable="d"
        WindowStartupLocation="CenterScreen"
        Closing="Window_Closing"
    Height="450" Width="800">
    <WindowChrome.WindowChrome>

        <WindowChrome
            CaptionHeight="0"
            CornerRadius="10"
            UseAeroCaptionButtons="False"
             ResizeBorderThickness="6"
            GlassFrameThickness="-1" />

    </WindowChrome.WindowChrome>
    <Window.Resources>
        <Style TargetType="ListBoxItem">
            <!-- 让内容水平拉伸，内边距等 -->
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="Padding" Value="12,10"/>
            <Setter Property="Margin" Value="0"/>
            <Setter Property="Background" Value="{StaticResource BackgroundBrush}"/>
           
       
            <Setter Property="Cursor" Value="Hand"/>

            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Border x:Name="bd" Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                              >
                            <ContentPresenter Margin="6,0"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsMouseOver" Value="True"/>
                                    <Condition Property="IsSelected" Value="False"/>
                                </MultiTrigger.Conditions>

                                <Setter TargetName="bd" Property="Background" Value="#DAE4F1"/>

                            </MultiTrigger>
                            <Trigger Property="IsSelected" Value="True">
                                
                                <Setter TargetName="bd" Property="Background" Value="#5880B2"/>
                              
                                <Setter Property="BorderBrush" Value="#3688F1"/>
                               
                                <Setter Property="Foreground" Value="White"/>
                            </Trigger>  
                            <Trigger Property="IsMouseOver" Value="True">
                                
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- DataTemplate：不要显式绑定到模型的 Foreground，改为继承 ListBoxItem 的 Foreground -->
        <DataTemplate DataType="{x:Type vm:ToolNavItem}">
            <DockPanel>
                <TextBlock Text="{Binding Icon}"
                           FontFamily="{StaticResource ttfFont}"
                           Foreground="{Binding Foreground}"
                           FontSize="16" Margin="2,0,8,0" />
                <StackPanel>
                    <TextBlock Text="{Binding Title}" FontWeight="SemiBold"/>
                    <TextBlock Text="{Binding Subtitle}"  FontSize="11"/>
                </StackPanel>
            </DockPanel>
        </DataTemplate>

        <!-- 其余 DataTemplate 保持不变 -->
        <DataTemplate DataType="{x:Type toolvm:UpCamLightViewModel}">
            <local:UpCamLightView/>
        </DataTemplate>
        <DataTemplate DataType="{x:Type toolvm:DownCamLightViewModel}">
            <local:DownCamLightView/>
        </DataTemplate>
        <DataTemplate DataType="{x:Type toolvm:MapCamLightViewModel}">
            <local:MapCamLightView/>
        </DataTemplate>
        <DataTemplate DataType="{x:Type toolvm:VisionDisplayTestViewModel}">
            <local:VisionDisplayTestView/>
        </DataTemplate>
    </Window.Resources>

    <Grid>
        <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
        <Border BorderThickness="1"   BorderBrush="#8829F5" Grid.RowSpan="2"/>
        <Grid MouseDown="Border_MouseDown" Opacity="0.8" Background="#205496">

                <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="{DynamicResource ToolBox}" FontSize="18" FontWeight="Bold" Foreground="White" Margin="20,5"/>
                <Button Margin="34,2" Click="MinClick" BorderBrush="White" FontSize="18" HorizontalAlignment="Right" Style="{StaticResource TitleBarMinButtonStyle}"/>
                <Button Margin="4,2" Click="CloseClick" BorderBrush="White" FontSize="18" HorizontalAlignment="Right" Style="{StaticResource TitleBarCloseButtonStyle}"/>

            </Grid>
            <Grid Background="{StaticResource BackgroundBrush}" Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <ListBox x:Name="ToolBoxListBox"
                         Style="{x:Null}"
                  Background="#E4E8EA" 
                  BorderThickness="0" 
                  SelectedItem="{Binding SelectedTool}"
                  ItemsSource="{Binding Tools}"
                  >

                </ListBox>
                <ContentControl Grid.Column="1" 
                         Content="{Binding SelectedTool.ContentViewModel}" 
                         Margin="10,0,0,0"/>
            </Grid>
        </Grid>
   
</Window>
