UsrPrintTemplateleft.xaml 9.4 KB
<UserControl x:Class="SmartScan.SetControl.WPF.UsrPrintTemplateleft"
             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:SmartScan.SetControl.WPF"
          Loaded="UserControl_Loaded"
             mc:Ignorable="d" >
    <UserControl.Resources>
        <Style TargetType="TextBlock">
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
        </Style>
        <Style TargetType="Button">
            <Setter Property="Background" Value="#1c1c1c"/>
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="BorderBrush" Value="#0078d7"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="Padding" Value="10,5"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Border Background="{TemplateBinding Background}"
                           BorderBrush="{TemplateBinding BorderBrush}"
                           BorderThickness="{TemplateBinding BorderThickness}">
                            <ContentPresenter HorizontalAlignment="Center" 
                                         VerticalAlignment="Center"
                                         Margin="{TemplateBinding Padding}"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Background" Value="#0078d7"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter Property="Background" Value="#005a9e"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Grid>
        <!-- 左侧面板 - 标签模板列表 -->
        <Grid >
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <Border Grid.Row="0" Background="#1A1A1A" BorderBrush="#0078d7" BorderThickness="1" Padding="10,5">
                <TextBlock Text="标签模板" Name="UsrPrintTemplate_pnlPrintTmpLst" FontFamily="微软雅黑" FontSize="14"  HorizontalAlignment="Center"/>
            </Border>

            <ListView x:Name="LstLabel" Grid.Row="1"  
              Background="#1c1c1c" 
              BorderThickness="1"
              BorderBrush="#0078d7"
              Foreground="White"
              SelectionChanged="LstLabel_SelectedIndexChanged"
                         SelectedIndex="-1"
          HorizontalContentAlignment="Center">
                <!-- 设置交替行数为2 -->
                <ListView.AlternationCount>2</ListView.AlternationCount>

                <!-- 自定义每个项的显示模板 -->
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding}" FontSize="14" FontFamily="微软雅黑"/>
                    </DataTemplate>
                </ListView.ItemTemplate>

                <ListView.ItemContainerStyle>
                    <Style TargetType="ListViewItem">
                        <Setter Property="HorizontalContentAlignment" Value="Center"/>
                        <Setter Property="VerticalContentAlignment" Value="Center"/>
                        <Setter Property="Height" Value="32"/>
                        <Setter Property="Padding" Value="10,0"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="ListViewItem">
                                    <Border x:Name="Border"
                                  Background="{TemplateBinding Background}"
                                  BorderThickness="0">
                                        <ContentPresenter HorizontalAlignment="Center" 
                                                VerticalAlignment="Center"/>
                                    </Border>
                                    <ControlTemplate.Triggers>
                                        <MultiTrigger>
                                            <MultiTrigger.Conditions>
                                                <Condition Property="IsSelected" Value="True"/>
                                                <Condition Property="Selector.IsSelectionActive" Value="True"/>
                                            </MultiTrigger.Conditions>
                                            <Setter TargetName="Border" Property="Background" Value="#005A9E"/>
                                        </MultiTrigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                        <Style.Triggers>
                            <!-- 交替行颜色 -->
                            <Trigger Property="ItemsControl.AlternationIndex" Value="0">
                                <Setter Property="Background" Value="#353535"/>
                            </Trigger>
                            <Trigger Property="ItemsControl.AlternationIndex" Value="1">
                                <Setter Property="Background" Value="#2a2a2a"/>
                            </Trigger>
                            <!-- 选中行颜色 - 只有在真正选中时才应用 -->
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="True"/>
                                    <Condition Property="Selector.IsSelectionActive" Value="True"/>
                                </MultiTrigger.Conditions>
                                <Setter Property="Background" Value="#0061c8"/>
                                <Setter Property="BorderBrush" Value="Transparent"/>
                            </MultiTrigger>

                      
                            <!-- 鼠标悬停效果 -->
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Background" Value="#464646"/>
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </ListView.ItemContainerStyle>
            </ListView>

            <Border Grid.Row="2" Background="#1A1A1A" BorderBrush="#0078d7" BorderThickness="1" Padding="5">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>

                    <TextBlock Grid.Row="0" FontFamily="微软雅黑" FontSize="14" Name="UsrPrintTemplate_pnlPrintTmpLstOp" Text="标签模板操作"  HorizontalAlignment="Center" Margin="0,0,0,10"/>

                    <UniformGrid Grid.Row="1" Rows="1" Columns="4" Margin="0,5">
                        <Button Margin="2" Click="BtnAddLabel_Click">
                            <StackPanel>
                                <TextBlock Text="+" FontSize="18" FontFamily="微软雅黑" HorizontalAlignment="Center"/>
                                <TextBlock  x:Name="UsrPrintTemplate_BtnAddLabel" Text="新建标签"  FontFamily="微软雅黑" FontSize="14" HorizontalAlignment="Center"/>
                            </StackPanel>
                        </Button>
                        <Button  Margin="2" Click="BtnDelLabel_Click">
                            <StackPanel>
                                <TextBlock Text="-" FontSize="18" FontFamily="微软雅黑"  HorizontalAlignment="Center"/>
                                <TextBlock Text="删除标签" x:Name="UsrPrintTemplate_BtnDelLabel" FontFamily="微软雅黑" FontSize="14" HorizontalAlignment="Center"/>
                            </StackPanel>
                        </Button>
                        <Button Margin="2" Click="BtnCopyLabel_Click">
                            <StackPanel>
                                <TextBlock Text="⎘" FontSize="18" HorizontalAlignment="Center"/>
                                <TextBlock   x:Name="UsrPrintTemplate_BtnCopyLabel" Text="复制标签" FontFamily="微软雅黑" FontSize="14" HorizontalAlignment="Center"/>
                            </StackPanel>
                        </Button>
                        <Button  Margin="2" Click="BtnRenameLabel_Click">
                            <StackPanel>
                                <TextBlock Text="✎" FontSize="18" HorizontalAlignment="Center"/>
                                <TextBlock  x:Name="UsrPrintTemplate_BtnRenameLabel" Text="重命名" FontFamily="微软雅黑" FontSize="14" HorizontalAlignment="Center"/>
                            </StackPanel>
                        </Button>
                    </UniformGrid>
                </Grid>
            </Border>
        </Grid>
    </Grid>
</UserControl>