BookmarkContent.xaml 11 KB

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