BookmarkContent.xaml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. <!-- IsHitTestVisible="False" -->
  43. <TextBox
  44. Name="TxtTitleInput"
  45. Grid.Column="1"
  46. Padding="5"
  47. HorizontalContentAlignment="Left"
  48. Background="White"
  49. BorderThickness="1"
  50. FontSize="14"
  51. Text="{Binding Title}"
  52. TextWrapping="Wrap">
  53. <i:Interaction.Triggers>
  54. <i:EventTrigger EventName="LostFocus">
  55. <helper:AdvancedInvokeCommandAction
  56. Command="{Binding DataContext.LostFocusCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
  57. CommandParameter="{Binding ElementName=TxtTitleInput}"
  58. PassEventArgsToCommand="True" />
  59. </i:EventTrigger>
  60. <!--<i:EventTrigger EventName="GotFocus">
  61. <helper:AdvancedInvokeCommandAction
  62. Command="{Binding DataContext.GotFocusCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
  63. CommandParameter="{Binding ElementName=TxtTitleInput}"
  64. PassEventArgsToCommand="True" />
  65. </i:EventTrigger>-->
  66. </i:Interaction.Triggers>
  67. </TextBox>
  68. <TextBlock
  69. Name="TxbTitle"
  70. Grid.Column="1"
  71. Padding="5"
  72. Background="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=Background}"
  73. FontSize="14"
  74. Text="{Binding Title}"
  75. Visibility="Visible" />
  76. </Grid>
  77. <i:Interaction.Triggers>
  78. <i:EventTrigger EventName="MouseEnter">
  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. <helper:AdvancedInvokeCommandAction
  92. Command="{Binding DataContext.MouseEnterCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
  93. CommandParameter="{Binding ElementName=Grid}"
  94. PassEventArgsToCommand="True" />
  95. <!-- 绑定多个参数 -->
  96. <!--<helper:AdvancedInvokeCommandAction Command="{Binding DataContext.MouseEnterCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" PassEventArgsToCommand="True">
  97. <helper:AdvancedInvokeCommandAction.CommandParameter>
  98. <MultiBinding Converter="{StaticResource ResourceKey=ObjectConvert}" Mode="TwoWay">
  99. <MultiBinding.Bindings>
  100. <Binding ElementName="Grid" />
  101. <Binding ElementName="TextBlockTitle" />
  102. </MultiBinding.Bindings>
  103. </MultiBinding>
  104. </helper:AdvancedInvokeCommandAction.CommandParameter>
  105. </helper:AdvancedInvokeCommandAction>-->
  106. <!-- 绑定一个参数 -->
  107. <!--<i:InvokeCommandAction Command="{Binding DataContext.MouseEnterCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" PassEventArgsToCommand="True" />-->
  108. </i:EventTrigger>
  109. <i:EventTrigger EventName="MouseLeave">
  110. <helper:AdvancedInvokeCommandAction
  111. Command="{Binding DataContext.MouseLeaveCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
  112. CommandParameter="{Binding ElementName=Grid}"
  113. PassEventArgsToCommand="True" />
  114. <!--<i:InvokeCommandAction Command="{Binding DataContext.MouseLeaveCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" PassEventArgsToCommand="True" />-->
  115. </i:EventTrigger>
  116. </i:Interaction.Triggers>
  117. </StackPanel>
  118. </DataTemplate>
  119. </ResourceDictionary>
  120. </UserControl.Resources>
  121. <Grid Background="#F2F2F2">
  122. <Grid.RowDefinitions>
  123. <RowDefinition Height="40" />
  124. <RowDefinition />
  125. </Grid.RowDefinitions>
  126. <Grid MinWidth="190">
  127. <TextBlock
  128. x:Name="TxtTitle"
  129. Margin="12,0,0,0"
  130. HorizontalAlignment="Left"
  131. VerticalAlignment="Center"
  132. FontSize="18"
  133. FontWeight="SemiBold"
  134. Text="Bookmarks" />
  135. <Button
  136. Name="BtnAddBookmark"
  137. Width="40"
  138. Height="40"
  139. Margin="0,0,0,0"
  140. HorizontalAlignment="Right"
  141. Command="{Binding AddBookmarkCommand}"
  142. CommandParameter="{Binding ElementName=BookMarkListView}"
  143. Content="添加" />
  144. </Grid>
  145. <Grid Grid.Row="1">
  146. <ListView
  147. Name="BookMarkListView"
  148. HorizontalContentAlignment="Stretch"
  149. Background="#F2F2F2"
  150. BorderThickness="0"
  151. ItemTemplate="{StaticResource myDataTemplate}"
  152. ItemsSource="{Binding Bookmarklist}"
  153. ScrollViewer.HorizontalScrollBarVisibility="Disabled"
  154. VirtualizingPanel.CacheLength="1"
  155. VirtualizingPanel.CacheLengthUnit="Page"
  156. VirtualizingPanel.IsVirtualizing="True"
  157. VirtualizingPanel.ScrollUnit="Pixel">
  158. <ListView.ItemsPanel>
  159. <ItemsPanelTemplate>
  160. <VirtualizingStackPanel Margin="-5,0,0,0" Background="Transparent" />
  161. </ItemsPanelTemplate>
  162. </ListView.ItemsPanel>
  163. <ListView.ItemContainerStyle>
  164. <Style BasedOn="{StaticResource ListViewItemGraySelectStyle}" TargetType="ListViewItem">
  165. <EventSetter Event="PreviewMouseLeftButtonDown" Handler="ListViewItem_MouseLeftButtonDown" />
  166. <EventSetter Event="LostFocus" Handler="ListViewItem_LostFocus" />
  167. <!--<EventSetter Event="PreviewMouseMove" Handler="ListViewItem_PreviewMouseMove" />
  168. <EventSetter Event="MouseLeave" Handler="ListViewItem_MouseLeave" />-->
  169. <!--<EventSetter Event="Unselected" Handler="ListViewItem_Unselected" />-->
  170. </Style>
  171. </ListView.ItemContainerStyle>
  172. <ListView.ContextMenu>
  173. <ContextMenu Width="200">
  174. <MenuItem
  175. Command="{Binding RenameCommand}"
  176. CommandParameter="{Binding PlacementTarget.SelectedItem, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
  177. Header="重命名" />
  178. <MenuItem
  179. Command="{Binding EditPageIndexCommand}"
  180. CommandParameter="{Binding PlacementTarget.SelectedItem, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
  181. Header="更改目标位置" />
  182. <MenuItem
  183. Command="{Binding DeleteCommand}"
  184. CommandParameter="{Binding PlacementTarget.SelectedItem, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
  185. Header="删除" />
  186. </ContextMenu>
  187. </ListView.ContextMenu>
  188. </ListView>
  189. </Grid>
  190. <StackPanel
  191. Name="EmptyPanel"
  192. Grid.RowSpan="2"
  193. Width="150"
  194. VerticalAlignment="Center"
  195. Visibility="{Binding IsEmptyPanelVisibility}">
  196. <Image
  197. Width="140"
  198. Height="140"
  199. Source="\Resources\BOTA\empty_bookmark.png" />
  200. <TextBlock
  201. Name="txtEmpty"
  202. Margin="0,12,0,0"
  203. FontFamily="Segoe UI"
  204. FontSize="16"
  205. Text="No bookmark"
  206. TextAlignment="Center" />
  207. </StackPanel>
  208. </Grid>
  209. </UserControl>