<UserControl x:Class="AIStudio.Wpf.DiagramApp.Views.ToolBoxControl"
             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:views="clr-namespace:AIStudio.Wpf.DiagramApp.Views"
             xmlns:viewmodels="clr-namespace:AIStudio.Wpf.DiagramApp.ViewModels"
             xmlns:model="clr-namespace:AIStudio.Wpf.DiagramApp.Models"
             xmlns:flowchartmodel="clr-namespace:AIStudio.Wpf.Flowchart.Models;assembly=AIStudio.Wpf.Flowchart"
             xmlns:sfcmodel="clr-namespace:AIStudio.Wpf.SFC.Models;assembly=AIStudio.Wpf.SFC"
             xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram" 
             xmlns:conventer="clr-namespace:AIStudio.Wpf.DiagramDesigner.Additionals.Converters;assembly=AIStudio.Wpf.DiagramDesigner.Additionals"
             xmlns:command="clr-namespace:AIStudio.Wpf.DiagramDesigner.Additionals.Commands;assembly=AIStudio.Wpf.DiagramDesigner.Additionals"
             xmlns:svg="https://gitee.com/akwkevin/aistudio.-wpf.-test/tree/master/Controls/AIStudio.Wpf.Svg2XamlExtension"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <ResourceDictionary>
            <conventer:StringPathConverter x:Key="stringPathConverter"/>
            <conventer:IntVisibilityConverter x:Key="IntVisibilityConverter"/>
            <dd:EnumDescriptionConverter x:Key="EnumDescriptionConverter"/>
            <command:CommandReference x:Key="DeleteItemCommandReference" Command="{Binding DeleteItemCommand}"/>


            <DataTemplate DataType="{x:Type model:ImageToolBoxData}">
                <Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
                    <Rectangle Name="Border"
                                   StrokeThickness="1"
                                   StrokeDashArray="2"
                                   Fill="Transparent"
                                   SnapsToDevicePixels="true"/>
                    <Image IsHitTestVisible="True"
                                       Stretch="Fill"
                                       Margin="2"
                                       Source="{Binding Icon, Converter={x:Static dd:ImageUrlConverter.Instance}}" />
                </Grid>
                <DataTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="true">
                        <Setter TargetName="Border" Property="Stroke" Value="Gray"/>
                    </Trigger>
                </DataTemplate.Triggers>
            </DataTemplate>
            <DataTemplate DataType="{x:Type model:MediaToolBoxData}">
                <Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
                    <Rectangle Name="Border"
                                   StrokeThickness="1"
                                   StrokeDashArray="2"
                                   Fill="Transparent"
                                   SnapsToDevicePixels="true"/>
                    <Image IsHitTestVisible="True"
                                       Stretch="Fill"
                                       Margin="2"
                                       Source="{Binding Text, Converter={x:Static dd:ImageUrlConverter.Instance}}" />
                </Grid>
                <DataTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="true">
                        <Setter TargetName="Border" Property="Stroke" Value="Gray"/>
                    </Trigger>
                </DataTemplate.Triggers>
            </DataTemplate>
            <DataTemplate DataType="{x:Type model:TextToolBoxData}">
                <Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
                    <Rectangle Name="Border"
                                   StrokeThickness="1"
                                   StrokeDashArray="2"
                                   Fill="Transparent"
                                   SnapsToDevicePixels="true"/>
                    <Rectangle Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}" Margin="2"/>
                    <TextBlock Text="{Binding Text}" FontSize="11" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </Grid>
                <DataTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="true">
                        <Setter TargetName="Border" Property="Stroke" Value="Gray"/>
                    </Trigger>
                </DataTemplate.Triggers>
            </DataTemplate>
            <DataTemplate DataType="{x:Type model:EllipseTextToolBoxData}">
                <Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
                    <Ellipse Name="Border"
                                   StrokeThickness="1"
                                   StrokeDashArray="2"
                                   Fill="Transparent"
                                   SnapsToDevicePixels="true"/>
                    <Ellipse Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}" Margin="2"/>
                    <TextBlock Text="{Binding Text}" FontSize="11" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </Grid>
                <DataTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="true">
                        <Setter TargetName="Border" Property="Stroke" Value="Gray"/>
                    </Trigger>
                </DataTemplate.Triggers>
            </DataTemplate>
            <DataTemplate DataType="{x:Type model:PathToolBoxData}">
                <Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
                    <Rectangle Name="Border"
                                   StrokeThickness="1"
                                   StrokeDashArray="2"
                                   Fill="Transparent"
                                   SnapsToDevicePixels="true"/>
                    <Path Style="{StaticResource PathItemStyle}" ToolTip="Document" Margin="2"/>
                </Grid>
                <DataTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="true">
                        <Setter TargetName="Border" Property="Stroke" Value="Gray"/>
                    </Trigger>
                </DataTemplate.Triggers>
            </DataTemplate>
            <DataTemplate DataType="{x:Type model:SvgToolBoxData}">
                <Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
                    <Rectangle Name="Border"
                                   StrokeThickness="1"
                                   StrokeDashArray="2"
                                   Fill="Transparent"
                                   SnapsToDevicePixels="true"/>
                    <svg:PackSvg Width="Auto" Height="Auto" Path="{Binding Icon}" Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}"/>
                </Grid>
                <DataTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="true">
                        <Setter TargetName="Border" Property="Stroke" Value="Gray"/>
                    </Trigger>
                </DataTemplate.Triggers>
            </DataTemplate>
            <DataTemplate DataType="{x:Type model:DesignerItemToolBoxData}">
                <Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
                    <Grid.ContextMenu>
                        <ContextMenu>
                            <MenuItem Header="删除" Command="{StaticResource DeleteItemCommandReference}" CommandParameter="{Binding .}"/>
                        </ContextMenu>
                    </Grid.ContextMenu>
                    <Rectangle Name="Border"
                                   StrokeThickness="1"
                                   StrokeDashArray="2"
                                   Fill="Transparent"
                                   SnapsToDevicePixels="true"/>
                    <Viewbox Stretch="Uniform" DataContext="{Binding DesignerItemViewModel}" Margin="2">
                        <Grid  Width="{Binding ItemWidth}" Height="{Binding ItemHeight}" IsHitTestVisible="False">
                            <ContentControl Content="{Binding .}" />
                            <TextBox Text="{Binding Text}" 
                                       IsReadOnly="True"
                                       TextWrapping="Wrap"
                                       Background ="Transparent"
                                       BorderThickness="0"
                                       Margin="5" 
                                       Foreground="{Binding FontViewModel.FontColor,Converter={StaticResource ColorBrushConverter}}"
                                       FontSize="{Binding FontViewModel.FontSize}" 
                                       FontFamily="{Binding FontViewModel.FontFamily}"  
                                       FontWeight="{Binding FontViewModel.FontWeight}"
                                       FontStyle="{Binding FontViewModel.FontStyle}"                         
                                       FontStretch="{Binding FontViewModel.FontStretch}"
                                       TextDecorations="{Binding FontViewModel.TextDecorations}"
                                       HorizontalContentAlignment="{Binding FontViewModel.HorizontalAlignment}"
                                       VerticalContentAlignment="{Binding FontViewModel.VerticalAlignment}"
                                       TextBlock.LineHeight="{Binding FontViewModel.LineHeight}"/>
                        </Grid>
                    </Viewbox>

                </Grid>
                <DataTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="true">
                        <Setter TargetName="Border" Property="Stroke" Value="Gray"/>
                    </Trigger>
                </DataTemplate.Triggers>
            </DataTemplate>
            <DataTemplate DataType="{x:Type model:MultipleDesignerItemToolBoxData}">
                <Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
                    <Grid.ContextMenu>
                        <ContextMenu>
                            <MenuItem Header="删除" Command="{StaticResource DeleteItemCommandReference}" CommandParameter="{Binding .}"/>
                        </ContextMenu>
                    </Grid.ContextMenu>
                    <Rectangle Name="Border"
                                   StrokeThickness="1"
                                   StrokeDashArray="2"
                                   Fill="Transparent"
                                   SnapsToDevicePixels="true"/>
                    <Viewbox Stretch="Uniform" Margin="2">
                        <ItemsControl ItemsSource="{Binding SelectableDesignerItemViewModels}" 
                                      Width="{Binding CanvasWidth}"
                                      Height="{Binding CanvasHeight}">
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <Canvas x:Name="rootCanvas"/>
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                            <ItemsControl.Template>
                                <ControlTemplate TargetType="{x:Type ItemsControl}">
                                    <Grid>
                                        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
                                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                        </Border>
                                    </Grid>
                                </ControlTemplate>
                            </ItemsControl.Template>
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <Grid  Width="{Binding ItemWidth}" Height="{Binding ItemHeight}" IsHitTestVisible="False">
                                        <ContentControl Content="{Binding .}" Margin="2"/>
                                    </Grid>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                            <ItemsControl.Resources>
                                <Style TargetType="{x:Type ContentPresenter}">
                                    <Setter Property="Canvas.Left" Value="{Binding Left}" />
                                    <Setter Property="Canvas.Top" Value="{Binding Top}" />
                                </Style>
                            </ItemsControl.Resources>
                        </ItemsControl>
                    </Viewbox>

                </Grid>
                <DataTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="true">
                        <Setter TargetName="Border" Property="Stroke" Value="Gray"/>
                    </Trigger>
                </DataTemplate.Triggers>
            </DataTemplate>
            <DataTemplate DataType="{x:Type flowchartmodel:FlowchartToolBoxData}">
                <Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
                    <Rectangle Name="Border"
                                   StrokeThickness="1"
                                   StrokeDashArray="2"
                                   Fill="Transparent"
                                   SnapsToDevicePixels="true"/>
                    <Grid IsHitTestVisible="False">
                        <ContentControl Style="{StaticResource CustomFlowNodeStyle}" Margin="2"/>
                        <TextBlock Text="{Binding Text}" Margin="5" TextWrapping="WrapWithOverflow" FontSize="9" Foreground="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Grid>
                </Grid>
                <DataTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="true">
                        <Setter TargetName="Border" Property="Stroke" Value="Gray"/>
                    </Trigger>
                </DataTemplate.Triggers>
            </DataTemplate>
            <DataTemplate DataType="{x:Type sfcmodel:SFCToolBoxData}">
                <Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Kind,Converter={StaticResource EnumDescriptionConverter}}">
                    <Rectangle Name="Border"
                                   StrokeThickness="1"
                                   StrokeDashArray="2"
                                   Fill="Transparent"
                                   SnapsToDevicePixels="true"/>
                    <Grid IsHitTestVisible="False">
                        <ContentControl Style="{StaticResource CustomSFCNodeStyle}" Margin="2" />
                    </Grid>
                </Grid>
                <DataTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="true">
                        <Setter TargetName="Border" Property="Stroke" Value="Gray"/>
                    </Trigger>
                </DataTemplate.Triggers>
            </DataTemplate>
            <DataTemplate DataType="{x:Type viewmodels:ToolBoxCategory}">
                <Grid Visibility="{Binding IsChecked,Converter={StaticResource boolToVisibilityConverter}}">
                    <Expander Header="{Binding Header}" 
                                                  IsExpanded="{Binding IsExpanded}" 
                                                  BorderThickness="0" 
                                                  Background="Transparent" 
                                                  Foreground="{DynamicResource Fluent.Ribbon.Brushes.LabelTextBrush}" 
                                                  Style="{StaticResource DefaultAnimationExpander}">
                        <ItemsControl  ItemsSource="{Binding ToolBoxItems}">
                            <ItemsControl.Template>
                                <ControlTemplate TargetType="{x:Type ItemsControl}">
                                    <Border BorderThickness="{TemplateBinding Border.BorderThickness}"
                                                    Padding="{TemplateBinding Control.Padding}"
                                                    BorderBrush="{TemplateBinding Border.BorderBrush}"
                                                    Background="{TemplateBinding Panel.Background}"
                                                    SnapsToDevicePixels="True">
                                        <ScrollViewer VerticalScrollBarVisibility="Auto">
                                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                                        </ScrollViewer>
                                    </Border>
                                </ControlTemplate>
                            </ItemsControl.Template>
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <WrapPanel Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ItemsControl}}, Path=ActualWidth}"/>
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                            <ItemsControl.ItemContainerStyle>
                                <Style TargetType="{x:Type ContentPresenter}">
                                    <Setter Property="Control.Padding"
                                    Value="10" />
                                    <Setter Property="ContentControl.HorizontalContentAlignment"
                                    Value="Stretch" />
                                    <Setter Property="ContentControl.VerticalContentAlignment"
                                    Value="Stretch" />
                                    <Setter Property="ToolTip"
                                    Value="{Binding ToolTip}" />
                                    <Setter Property="dd:DragAndDropProps.EnabledForDrag"
                                    Value="True" />
                                </Style>
                            </ItemsControl.ItemContainerStyle>
                        </ItemsControl>
                    </Expander>
                    <Button Margin="5" ToolTip="移除" Command="{Binding DataContext.DeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" CommandParameter="{Binding .}" Width="16" Height="16" HorizontalAlignment="Right" VerticalAlignment="Top" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="Transparent">
                        <Path Stretch="Fill" Margin="2" Fill="Red" Data="M0.7,0 L5,4.3 L9.3,0 L10,0.7 L5.7,5 L10,9.3 L9.3,10 L5,5.7 L0.7,10 L0,9.3 L4.3,5 L0,0.7 z" ></Path>
                    </Button>
                </Grid>
            </DataTemplate>

            <DataTemplate DataType="{x:Type viewmodels:MineToolBoxCategory}">
                <Grid Visibility="{Binding IsChecked,Converter={StaticResource boolToVisibilityConverter}}">
                    <Expander Header="{Binding Header}" 
                                                  IsExpanded="{Binding IsExpanded}" 
                                                  BorderThickness="0" 
                                                  Background="Transparent" 
                                                  Foreground="{DynamicResource Fluent.Ribbon.Brushes.LabelTextBrush}" 
                                                  Style="{StaticResource DefaultAnimationExpander}">
                        <Grid>
                            <Border BorderThickness="1" CornerRadius="5" Margin="5" Padding="10" Visibility="{Binding ToolBoxItems.Count, Converter={StaticResource IntVisibilityConverter}, ConverterParameter='0'}">
                                <Border.BorderBrush>
                                    <LinearGradientBrush SpreadMethod="Repeat" StartPoint="0,5" EndPoint="5,0" MappingMode="Absolute">
                                        <LinearGradientBrush.GradientStops>
                                            <GradientStop Color="{DynamicResource Fluent.Ribbon.Colors.AccentBaseColor}" Offset="0"/>
                                            <GradientStop Color="{DynamicResource Fluent.Ribbon.Colors.AccentBaseColor}" Offset="0.2"/>
                                            <GradientStop Color="Transparent" Offset="0.4"/>
                                            <GradientStop Color="Transparent" Offset="0.6"/>
                                            <GradientStop Color="{DynamicResource Fluent.Ribbon.Colors.AccentBaseColor}" Offset="0.8"/>
                                            <GradientStop Color="{DynamicResource Fluent.Ribbon.Colors.AccentBaseColor}" Offset="1"/>
                                        </LinearGradientBrush.GradientStops>
                                    </LinearGradientBrush>
                                </Border.BorderBrush>

                                <TextBlock Text="添加形状到我的符号" HorizontalAlignment="Center" Foreground="{DynamicResource GrayBrush2}"/>
                            </Border>
                            <ItemsControl  ItemsSource="{Binding ToolBoxItems}">
                                <ItemsControl.Template>
                                    <ControlTemplate TargetType="{x:Type ItemsControl}">
                                        <Border BorderThickness="{TemplateBinding Border.BorderThickness}"
                                                    Padding="{TemplateBinding Control.Padding}"
                                                    BorderBrush="{TemplateBinding Border.BorderBrush}"
                                                    Background="{TemplateBinding Panel.Background}"
                                                    SnapsToDevicePixels="True">
                                            <ScrollViewer VerticalScrollBarVisibility="Auto">
                                                <ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                                            </ScrollViewer>
                                        </Border>
                                    </ControlTemplate>
                                </ItemsControl.Template>
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <WrapPanel Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ItemsControl}}, Path=ActualWidth}"/>
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                                <ItemsControl.ItemContainerStyle>
                                    <Style TargetType="{x:Type ContentPresenter}">
                                        <Setter Property="Control.Padding"
                                    Value="10" />
                                        <Setter Property="ContentControl.HorizontalContentAlignment"
                                    Value="Stretch" />
                                        <Setter Property="ContentControl.VerticalContentAlignment"
                                    Value="Stretch" />
                                        <Setter Property="ToolTip"
                                    Value="{Binding ToolTip}" />
                                        <Setter Property="dd:DragAndDropProps.EnabledForDrag"
                                    Value="True" />
                                    </Style>
                                </ItemsControl.ItemContainerStyle>
                            </ItemsControl>
                        </Grid>
                    </Expander>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top">
                        <Button Margin="0,5,2,5" ToolTip="导入到我的符号" Command="{Binding DataContext.ImportItemCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" Width="16" Height="16"  Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="Transparent">
                            <Path Stretch="Fill" Margin="2" Fill="{DynamicResource GrayBrush2}" Data="M14,12L10,8V11H2V13H10V16M20,18V6C20,4.89 19.1,4 18,4H6A2,2 0 0,0 4,6V9H6V6H18V18H6V15H4V18A2,2 0 0,0 6,20H18A2,2 0 0,0 20,18Z" ></Path>
                        </Button>
                        <Button Margin="0,5,2,5" ToolTip="添加到我的符号" Command="{Binding DataContext.AddItemCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" Width="16" Height="16"  Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="Transparent">
                            <Path Stretch="Fill" Margin="2" Fill="{DynamicResource GrayBrush2}" Data="M938.666667 426.666667h-341.333334V85.333333c0-46.933333-38.4-85.333333-85.333333-85.333333s-85.333333 38.4-85.333333 85.333333v341.333334H85.333333c-46.933333 0-85.333333 38.4-85.333333 85.333333s38.4 85.333333 85.333333 85.333333h341.333334v341.333334c0 46.933333 38.4 85.333333 85.333333 85.333333s85.333333-38.4 85.333333-85.333333v-341.333334h341.333334c46.933333 0 85.333333-38.4 85.333333-85.333333s-38.4-85.333333-85.333333-85.333333z" ></Path>
                        </Button>
                        <Button Margin="0,5,5,5" ToolTip="移除" Command="{Binding DataContext.DeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" CommandParameter="{Binding .}" Width="16" Height="16"  Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="Transparent">
                            <Path Stretch="Fill" Margin="2" Fill="Red" Data="M0.7,0 L5,4.3 L9.3,0 L10,0.7 L5.7,5 L10,9.3 L9.3,10 L5,5.7 L0.7,10 L0,9.3 L4.3,5 L0,0.7 z" ></Path>
                        </Button>
                    </StackPanel>
                </Grid>
            </DataTemplate>

        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Expander x:Name="expanderLeft" ExpandDirection="Left" IsExpanded="{Binding IsExpanded, RelativeSource={RelativeSource AncestorType=views:ToolBoxControl}}" Style="{StaticResource DefaultAutoHideExpander}" Margin="0,0,1,0">
            <Expander.Header>
                <DockPanel Height="26">
                    <ToggleButton DockPanel.Dock="Right" IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource AncestorType=views:ToolBoxControl}}" Background="{DynamicResource Fluent.Ribbon.Brushes.AccentBaseColorBrush}" Style="{StaticResource DefaultToggleButton}">
                        <Path Fill="Black" Stretch="Fill" Width="16" Height="16" Margin="10,3"  Data="M18.41,7.41L17,6L11,12L17,18L18.41,16.59L13.83,12L18.41,7.41M12.41,7.41L11,6L5,12L11,18L12.41,16.59L7.83,12L12.41,7.41Z"/>
                    </ToggleButton>
                    <TextBlock Text="符号库" DockPanel.Dock="Left" VerticalAlignment="Center"/>
                </DockPanel>
            </Expander.Header>
            <Border>
                <Grid x:Name="grid" Width="225" MinWidth="100" MaxWidth="500">
                    <Grid.ContextMenu>
                        <ContextMenu ItemsSource="{Binding ToolBoxCategory}">
                            <ContextMenu.ItemContainerStyle>
                                <Style TargetType="MenuItem">
                                    <Setter Property="IsCheckable" Value="True" />
                                    <Setter Property="IsChecked" Value="{Binding IsChecked}"/>
                                </Style>
                            </ContextMenu.ItemContainerStyle>
                            <ContextMenu.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Header}" />
                                </DataTemplate>
                            </ContextMenu.ItemTemplate>
                        </ContextMenu>
                    </Grid.ContextMenu>
                    <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
                        <ItemsControl x:Name="listbox" ItemsSource="{Binding ToolBoxCategory}" Padding="0,0,0,0" BorderThickness="0">

                        </ItemsControl>
                    </ScrollViewer>
                </Grid>
            </Border>
        </Expander>
        <dd:BorderResizeThumb Width="1" Margin="-3,0,0,0" ResizeElement="{Binding ElementName=grid}" Cursor="SizeWE" HorizontalAlignment="Right" VerticalAlignment="Stretch" Visibility="{Binding IsExpanded, RelativeSource={RelativeSource AncestorType=views:ToolBoxControl},Converter={StaticResource BooleanToVisibilityConverter}}"/>
    </Grid>
</UserControl>
