BackgroundTemplateListFileContent.xaml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <UserControl x:Class="PDF_Office.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_Office.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. <Button Name="EditTemplateBtn" Height="43" Width="63" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="EditTemplateBtn_Click"></Button>
  59. <Button Name="DeleteTemplateBtn" Height="43" Width="63" HorizontalAlignment="Right" VerticalAlignment="Bottom" Click="DeleteTemplateBtn_Click">
  60. </Button>
  61. </Grid>
  62. </Border>
  63. </StackPanel>
  64. <DataTemplate.Triggers>
  65. <Trigger Property="IsMouseOver" Value="True">
  66. <Setter TargetName="EditTemplateBtn" Property="Visibility" Value="Visible"/>
  67. <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Visible"/>
  68. </Trigger>
  69. <Trigger Property="IsMouseOver" Value="False">
  70. <Setter TargetName="EditTemplateBtn" Property="Visibility" Value="Collapsed"/>
  71. <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Collapsed"/>
  72. </Trigger>
  73. </DataTemplate.Triggers>
  74. </DataTemplate>
  75. </ListBox.ItemTemplate>
  76. </ListBox>
  77. <Grid Width="140" Margin="64,153,56,0" Visibility="{Binding CreateTemplateVisible, Mode=OneWay}">
  78. <StackPanel Orientation="Vertical">
  79. <Label Height="87" Width="87" HorizontalAlignment="Center" Background="BlueViolet"></Label>
  80. <TextBlock Height="24" FontSize="14" Text="请先创建一个背景模板" Margin="0,8,0,0" VerticalAlignment="Center" ></TextBlock>
  81. <Button Height="24" Width="44" Margin="0,12,0,0" Content ="新建" Command="{Binding AddTemplateCommand}"></Button>
  82. </StackPanel>
  83. </Grid>
  84. </Grid>
  85. </UserControl>