BackgroundTemplateListFileContent.xaml 6.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <UserControl x:Class="PDF_Master.Views.EditTools.Background.BackgroundTemplateListFileContent"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:prism="http://prismlibrary.com/"
  5. prism:ViewModelLocator.AutoWireViewModel="True"
  6. xmlns:data ="clr-namespace:PDFSettings;assembly=PDFSettings"
  7. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  8. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:background="clr-namespace:PDF_Master.ViewModels.EditTools.Background" d:DataContext="{d:DesignInstance Type=background:BackgroundTemplateListFileContentViewModel}"
  9. mc:Ignorable="d"
  10. d:DesignHeight="632"
  11. d:DesignWidth="260">
  12. <UserControl.Resources>
  13. <ContextMenu x:Key="FlyoutMenu" FontSize="14" >
  14. <ContextMenu.ItemContainerStyle>
  15. <Style TargetType="{x:Type MenuItem}">
  16. <Setter Property="Padding" Value="0,8,0,8"/>
  17. <Setter Property="VerticalContentAlignment" Value="Center"/>
  18. </Style>
  19. </ContextMenu.ItemContainerStyle>
  20. <MenuItem Name="MenuEdit" Header="编辑模板" Click="MenuEdit_Click" >
  21. </MenuItem>
  22. <MenuItem Name="MenuDeleteCurrent" Header="删除模板" Click="MenuDeleteCurrent_Click">
  23. </MenuItem>
  24. <MenuItem Name="MenuDeleteAll" Header="删除全部" Click="MenuDeleteAll_Click"></MenuItem>
  25. </ContextMenu>
  26. </UserControl.Resources>
  27. <Grid Background="#F3F3F3">
  28. <ListBox
  29. Width="240"
  30. BorderThickness="0"
  31. ScrollViewer.CanContentScroll="True"
  32. ScrollViewer.HorizontalScrollBarVisibility="Disabled"
  33. ScrollViewer.VerticalScrollBarVisibility="Hidden"
  34. VirtualizingPanel.IsVirtualizing="True"
  35. VirtualizingPanel.VirtualizationMode="Standard"
  36. VirtualizingPanel.CacheLengthUnit="Page"
  37. VirtualizingPanel.CacheLength="1"
  38. VirtualizingPanel.ScrollUnit="Pixel"
  39. Background="#F3F3F3"
  40. ItemsSource="{Binding BackgroundModFileCollection}"
  41. SelectionChanged="ListBox_SelectionChanged">
  42. <ListBox.ItemContainerStyle>
  43. <Style TargetType="ListBoxItem">
  44. <Setter Property="Margin" Value="20"/>
  45. <Setter Property="Padding" Value="0 0 0 0"/>
  46. <Setter Property="Height" Value="160"/>
  47. <Setter Property="Width" Value="128"/>
  48. <Setter Property="ContextMenu" Value="{StaticResource FlyoutMenu}"/>
  49. <Setter Property="Template" Value="{DynamicResource EditToolsItemControlTemplate}"/>
  50. </Style>
  51. </ListBox.ItemContainerStyle>
  52. <ListBox.ItemTemplate>
  53. <DataTemplate DataType="{x:Type data:BackgroundItem}">
  54. <StackPanel Name="itemPanel" Loaded="itemPanel_Loaded">
  55. <Border BorderThickness="1" BorderBrush="#A0A2AE">
  56. <Grid Height="160" Width=" 128" >
  57. <Image Name="BackgroundPreview" Stretch="Fill" RenderOptions.BitmapScalingMode="HighQuality"/>
  58. <CheckBox Name="IsSelectedCheckBox" Height="14" Width="14" HorizontalAlignment="Right" VerticalAlignment="Top" Panel.ZIndex="1" IsChecked="True" IsEnabled="False"/>
  59. <Button Name="EditTemplateBtn" Height="43" Width="63" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="EditTemplateBtn_Click"></Button>
  60. <Button Name="DeleteTemplateBtn" Height="43" Width="63" HorizontalAlignment="Right" VerticalAlignment="Bottom" Click="DeleteTemplateBtn_Click">
  61. </Button>
  62. </Grid>
  63. </Border>
  64. </StackPanel>
  65. <DataTemplate.Triggers>
  66. <DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType=ListBoxItem}}" Value="True">
  67. <Setter TargetName="IsSelectedCheckBox" Property="Visibility" Value="Visible"/>
  68. </DataTrigger>
  69. <DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType=ListBoxItem}}" Value="False">
  70. <Setter TargetName="IsSelectedCheckBox" Property="Visibility" Value="Collapsed"/>
  71. </DataTrigger>
  72. <Trigger Property="IsMouseOver" Value="True">
  73. <Setter TargetName="EditTemplateBtn" Property="Visibility" Value="Visible"/>
  74. <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Visible"/>
  75. </Trigger>
  76. <Trigger Property="IsMouseOver" Value="False">
  77. <Setter TargetName="EditTemplateBtn" Property="Visibility" Value="Collapsed"/>
  78. <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Collapsed"/>
  79. </Trigger>
  80. </DataTemplate.Triggers>
  81. </DataTemplate>
  82. </ListBox.ItemTemplate>
  83. </ListBox>
  84. <Grid Width="140" Margin="64,153,56,0" Visibility="{Binding CreateTemplateVisible, Mode=OneWay}">
  85. <StackPanel Orientation="Vertical">
  86. <Label Height="87" Width="87" HorizontalAlignment="Center" Background="BlueViolet"></Label>
  87. <TextBlock Height="24" FontSize="14" Text="请先创建一个背景模板" Margin="0,8,0,0" VerticalAlignment="Center" ></TextBlock>
  88. <Button Height="24" Width="44" Margin="0,12,0,0" Content ="新建" Command="{Binding AddTemplateCommand}"></Button>
  89. </StackPanel>
  90. </Grid>
  91. </Grid>
  92. </UserControl>