BookmarkContent.xaml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <UserControl
  2. x:Class="PDF_Office.Views.BOTA.BookmarkContent"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:bota="clr-namespace:PDF_Office.ViewModels.BOTA"
  6. xmlns:convert="clr-namespace:PDF_Office.DataConvert"
  7. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  8. xmlns:data="clr-namespace:ComPDFKit.PDFDocument;assembly=ComPDFKit.Desk"
  9. xmlns:helper="clr-namespace:PDF_Office.Helper"
  10. xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
  11. xmlns:local="clr-namespace:PDF_Office.Views.BOTA"
  12. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  13. xmlns:prism="http://prismlibrary.com/"
  14. d:DataContext="{d:DesignInstance Type=bota:BookmarkContentViewModel}"
  15. d:DesignHeight="450"
  16. d:DesignWidth="300"
  17. prism:ViewModelLocator.AutoWireViewModel="True"
  18. mc:Ignorable="d">
  19. <UserControl.Resources>
  20. <ResourceDictionary>
  21. <ResourceDictionary.MergedDictionaries>
  22. <ResourceDictionary Source="/Styles/ListViewStyle.xaml" />
  23. </ResourceDictionary.MergedDictionaries>
  24. <convert:BoolToVisible x:Key="BoolToVisibleConvert" />
  25. <convert:UnVisivleConvert x:Key="UnVisivleConvert" />
  26. <convert:ObjectConvert x:Key="ObjectConvert" />
  27. <DataTemplate x:Key="myDataTemplate" DataType="{x:Type data:CPDFBookmark}">
  28. <StackPanel
  29. Name="StackPanel"
  30. HorizontalAlignment="Stretch"
  31. VerticalAlignment="Stretch">
  32. <Grid Name="Grid" Margin="15,5">
  33. <Grid.ColumnDefinitions>
  34. <ColumnDefinition Width="10*" />
  35. <ColumnDefinition Width="90*" />
  36. </Grid.ColumnDefinitions>
  37. <Image
  38. Grid.Column="0"
  39. Width="16"
  40. Height="16"
  41. Source="\Resources\BOTA\empty_bookmark.png" />
  42. <TextBox
  43. Name="TxtTitleInput"
  44. Grid.Column="1"
  45. Padding="5"
  46. HorizontalContentAlignment="Left"
  47. Background="White"
  48. BorderThickness="1"
  49. FontSize="14"
  50. Text="{Binding Title}"
  51. TextWrapping="Wrap">
  52. <i:Interaction.Triggers>
  53. <!--<i:EventTrigger EventName="LostFocus">
  54. <helper:AdvancedInvokeCommandAction
  55. Command="{Binding DataContext.LostFocusCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
  56. CommandParameter="{Binding ElementName=TxtTitleInput}"
  57. PassEventArgsToCommand="True" />
  58. </i:EventTrigger>-->
  59. <!--<i:EventTrigger EventName="GotFocus">
  60. <helper:AdvancedInvokeCommandAction
  61. Command="{Binding DataContext.GotFocusCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
  62. CommandParameter="{Binding ElementName=TxtTitleInput}"
  63. PassEventArgsToCommand="True" />
  64. </i:EventTrigger>-->
  65. </i:Interaction.Triggers>
  66. </TextBox>
  67. <TextBlock
  68. Name="TxbTitle"
  69. Grid.Column="1"
  70. Padding="5"
  71. Background="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=Background}"
  72. FontSize="14"
  73. Text="{Binding Title}"
  74. Visibility="Visible" />
  75. </Grid>
  76. <!--<i:Interaction.Triggers>
  77. <i:EventTrigger EventName="MouseEnter">
  78. -->
  79. <!-- 绑定两个或多个参数 -->
  80. <!--<i:InvokeCommandAction Command="{Binding DataContext.MouseEnterCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" PassEventArgsToCommand="True">
  81. <i:InvokeCommandAction.CommandParameter>
  82. <MultiBinding Converter="{StaticResource ResourceKey=ObjectConvert}" Mode="TwoWay">
  83. <MultiBinding.Bindings>
  84. <Binding ElementName="Grid" />
  85. <Binding ElementName="TxtTitleInput" />
  86. </MultiBinding.Bindings>
  87. </MultiBinding>
  88. </i:InvokeCommandAction.CommandParameter>
  89. </i:InvokeCommandAction>-->
  90. <!-- 绑定两个参数 -->
  91. <!--
  92. <helper:AdvancedInvokeCommandAction
  93. Command="{Binding DataContext.MouseEnterCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
  94. CommandParameter="{Binding ElementName=Grid}"
  95. PassEventArgsToCommand="True" />
  96. -->
  97. <!-- 绑定多个参数 -->
  98. <!--<helper:AdvancedInvokeCommandAction Command="{Binding DataContext.MouseEnterCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" PassEventArgsToCommand="True">
  99. <helper:AdvancedInvokeCommandAction.CommandParameter>
  100. <MultiBinding Converter="{StaticResource ResourceKey=ObjectConvert}" Mode="TwoWay">
  101. <MultiBinding.Bindings>
  102. <Binding ElementName="Grid" />
  103. <Binding ElementName="TextBlockTitle" />
  104. </MultiBinding.Bindings>
  105. </MultiBinding>
  106. </helper:AdvancedInvokeCommandAction.CommandParameter>
  107. </helper:AdvancedInvokeCommandAction>-->
  108. <!-- 绑定一个参数 -->
  109. <!--<i:InvokeCommandAction Command="{Binding DataContext.MouseEnterCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" PassEventArgsToCommand="True" />-->
  110. <!--
  111. </i:EventTrigger>
  112. <i:EventTrigger EventName="MouseLeave">
  113. <helper:AdvancedInvokeCommandAction
  114. Command="{Binding DataContext.MouseLeaveCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
  115. CommandParameter="{Binding ElementName=Grid}"
  116. PassEventArgsToCommand="True" />
  117. -->
  118. <!--<i:InvokeCommandAction Command="{Binding DataContext.MouseLeaveCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" PassEventArgsToCommand="True" />-->
  119. <!--
  120. </i:EventTrigger>
  121. </i:Interaction.Triggers>-->
  122. </StackPanel>
  123. </DataTemplate>
  124. </ResourceDictionary>
  125. </UserControl.Resources>
  126. <Grid Background="#F2F2F2">
  127. <Grid.RowDefinitions>
  128. <RowDefinition Height="40" />
  129. <RowDefinition />
  130. </Grid.RowDefinitions>
  131. <Grid MinWidth="190">
  132. <TextBlock
  133. x:Name="TxtTitle"
  134. Margin="12,0,0,0"
  135. HorizontalAlignment="Left"
  136. VerticalAlignment="Center"
  137. FontSize="18"
  138. FontWeight="SemiBold"
  139. Text="Bookmarks" />
  140. <Button
  141. Name="BtnAddBookmark"
  142. Width="40"
  143. Height="40"
  144. Margin="0,0,0,0"
  145. HorizontalAlignment="Right"
  146. Command="{Binding AddBookmarkCommand}"
  147. CommandParameter="{Binding ElementName=BookMarkListView}"
  148. Content="添加" />
  149. </Grid>
  150. <Grid Grid.Row="1">
  151. <ListView
  152. Name="BookMarkListView"
  153. HorizontalContentAlignment="Stretch"
  154. Background="#F2F2F2"
  155. BorderThickness="0"
  156. ItemTemplate="{StaticResource myDataTemplate}"
  157. ItemsSource="{Binding Bookmarklist}"
  158. PreviewMouseLeftButtonDown="BookMarkListView_PreviewMouseLeftButtonDown"
  159. ScrollViewer.HorizontalScrollBarVisibility="Disabled"
  160. VirtualizingPanel.CacheLength="1"
  161. VirtualizingPanel.CacheLengthUnit="Page"
  162. VirtualizingPanel.IsVirtualizing="True"
  163. VirtualizingPanel.ScrollUnit="Pixel">
  164. <ListView.ItemsPanel>
  165. <ItemsPanelTemplate>
  166. <VirtualizingStackPanel Margin="-5,0,0,0" Background="Transparent" />
  167. </ItemsPanelTemplate>
  168. </ListView.ItemsPanel>
  169. <ListView.ItemContainerStyle>
  170. <Style BasedOn="{StaticResource ListViewItemGraySelectStyle}" TargetType="ListViewItem">
  171. <EventSetter Event="PreviewMouseDown" Handler="ListViewItem_MouseLeftButtonDown" />
  172. <EventSetter Event="LostFocus" Handler="ListViewItem_LostFocus" />
  173. <!--<EventSetter Event="MouseLeave" Handler="ListViewItem_MouseLeave" />-->
  174. <!--<EventSetter Event="PreviewMouseMove" Handler="ListViewItem_PreviewMouseMove" />
  175. <EventSetter Event="MouseLeave" Handler="ListViewItem_MouseLeave" />-->
  176. <!--<EventSetter Event="Unselected" Handler="ListViewItem_Unselected" />-->
  177. </Style>
  178. </ListView.ItemContainerStyle>
  179. <ListView.ContextMenu>
  180. <ContextMenu Width="200">
  181. <MenuItem
  182. Command="{Binding RenameCommand}"
  183. CommandParameter="{Binding PlacementTarget.SelectedItem, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
  184. Header="重命名" />
  185. <MenuItem
  186. Command="{Binding EditPageIndexCommand}"
  187. CommandParameter="{Binding PlacementTarget.SelectedItem, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
  188. Header="更改目标位置" />
  189. <MenuItem
  190. Command="{Binding DeleteCommand}"
  191. CommandParameter="{Binding PlacementTarget.SelectedItem, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
  192. Header="删除" />
  193. </ContextMenu>
  194. </ListView.ContextMenu>
  195. </ListView>
  196. </Grid>
  197. <StackPanel
  198. Name="EmptyPanel"
  199. Grid.RowSpan="2"
  200. Width="150"
  201. VerticalAlignment="Center"
  202. Visibility="{Binding IsEmptyPanelVisibility}">
  203. <Image
  204. Width="140"
  205. Height="140"
  206. Source="\Resources\BOTA\empty_bookmark.png" />
  207. <TextBlock
  208. Name="txtEmpty"
  209. Margin="0,12,0,0"
  210. FontFamily="Segoe UI"
  211. FontSize="16"
  212. Text="No bookmark"
  213. TextAlignment="Center" />
  214. </StackPanel>
  215. </Grid>
  216. </UserControl>