SearchContent.xaml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <UserControl x:Class="PDF_Office.Views.BOTA.SearchContent"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:local="clr-namespace:PDF_Office.Views.BOTA"
  7. xmlns:prism="http://prismlibrary.com/"
  8. prism:ViewModelLocator.AutoWireViewModel="True"
  9. xmlns:bota="clr-namespace:PDF_Office.ViewModels.BOTA"
  10. d:DataContext="{d:DesignInstance Type=bota:SearchContentViewModel}"
  11. xmlns:helper="clr-namespace:PDF_Office.Helper"
  12. xmlns:convert="clr-namespace:PDF_Office.DataConvert"
  13. xmlns:customControl="clr-namespace:PDF_Office.CustomControl"
  14. xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
  15. mc:Ignorable="d"
  16. d:DesignHeight="450" d:DesignWidth="800">
  17. <UserControl.Resources>
  18. <convert:WidthConvert x:Key="WidthConvert"/>
  19. <convert:BoolToVisible x:Key="BoolToVisible"/>
  20. <convert:InvertBoolToVisibleConvert x:Key="InvertBoolToVisibleConvert"/>
  21. <Style x:Key="ListViewItemGraySelectStyle" TargetType="{x:Type ListViewItem}">
  22. <Setter Property="UIElement.SnapsToDevicePixels"
  23. Value="True" />
  24. <Setter Property="Control.Padding"
  25. Value="4,1" />
  26. <Setter Property="Control.HorizontalContentAlignment">
  27. <Setter.Value>
  28. <Binding Path="HorizontalContentAlignment"
  29. RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ItemsControl, AncestorLevel=1}" />
  30. </Setter.Value>
  31. </Setter>
  32. <Setter Property="Control.VerticalContentAlignment">
  33. <Setter.Value>
  34. <Binding Path="VerticalContentAlignment"
  35. RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ItemsControl, AncestorLevel=1}" />
  36. </Setter.Value>
  37. </Setter>
  38. <Setter Property="Panel.Background"
  39. Value="#00FFFFFF" />
  40. <Setter Property="Border.BorderBrush"
  41. Value="#00FFFFFF" />
  42. <Setter Property="Border.BorderThickness"
  43. Value="1" />
  44. <Setter Property="FrameworkElement.FocusVisualStyle">
  45. <Setter.Value>
  46. <Style TargetType="{x:Type IFrameworkInputElement}">
  47. <Setter Property="Control.Template">
  48. <Setter.Value>
  49. <ControlTemplate>
  50. <Rectangle Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
  51. StrokeThickness="1"
  52. StrokeDashArray="1 2"
  53. Margin="2"
  54. SnapsToDevicePixels="True" />
  55. </ControlTemplate>
  56. </Setter.Value>
  57. </Setter>
  58. </Style>
  59. </Setter.Value>
  60. </Setter>
  61. <Setter Property="Control.Template">
  62. <Setter.Value>
  63. <ControlTemplate TargetType="{x:Type ListViewItem}">
  64. <Border BorderThickness="{TemplateBinding Border.BorderThickness}"
  65. Padding="{TemplateBinding Control.Padding}"
  66. BorderBrush="{TemplateBinding Border.BorderBrush}"
  67. Background="{TemplateBinding Panel.Background}"
  68. Name="Bd"
  69. SnapsToDevicePixels="True">
  70. <ContentPresenter Content="{TemplateBinding ContentControl.Content}"
  71. ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
  72. ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}"
  73. HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
  74. VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
  75. SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
  76. </Border>
  77. <ControlTemplate.Triggers>
  78. <MultiTrigger>
  79. <MultiTrigger.Conditions>
  80. <Condition Property="UIElement.IsMouseOver" Value="True" />
  81. </MultiTrigger.Conditions>
  82. <Setter Property="Panel.Background" TargetName="Bd" Value="#1A000000" />
  83. <Setter Property="Border.BorderBrush" TargetName="Bd" Value="#1A000000" />
  84. </MultiTrigger>
  85. <MultiTrigger>
  86. <MultiTrigger.Conditions>
  87. <Condition Property="Selector.IsSelectionActive" Value="False" />
  88. <Condition Property="Selector.IsSelected" Value="True" />
  89. </MultiTrigger.Conditions>
  90. <Setter Property="Panel.Background" TargetName="Bd" Value="#1A477EDE" />
  91. <Setter Property="Border.BorderBrush" TargetName="Bd" Value="#1A477EDE" />
  92. </MultiTrigger>
  93. <MultiTrigger>
  94. <MultiTrigger.Conditions>
  95. <Condition Property="Selector.IsSelectionActive" Value="True" />
  96. <Condition Property="Selector.IsSelected" Value="True" />
  97. </MultiTrigger.Conditions>
  98. <Setter Property="Panel.Background" TargetName="Bd" Value="#1A477EDE" />
  99. <Setter Property="Border.BorderBrush" TargetName="Bd" Value="#1A477EDE" />
  100. </MultiTrigger>
  101. <Trigger Property="UIElement.IsEnabled" Value="False">
  102. <Setter Property="TextElement.Foreground" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
  103. </Trigger>
  104. </ControlTemplate.Triggers>
  105. </ControlTemplate>
  106. </Setter.Value>
  107. </Setter>
  108. </Style>
  109. </UserControl.Resources>
  110. <Grid Background="#F3F3F3" Width="200">
  111. <Grid.RowDefinitions>
  112. <RowDefinition Height="auto"/>
  113. <RowDefinition Height="auto"/>
  114. <RowDefinition Height="auto"/>
  115. <RowDefinition/>
  116. </Grid.RowDefinitions>
  117. <Grid Height="48" Margin="10,0,10,0">
  118. <TextBlock Text="查找" HorizontalAlignment="Left" VerticalAlignment="Center"/>
  119. <Button Content="完成" HorizontalAlignment="Right" VerticalAlignment="Center" Command="{Binding SearchTextCommand}"/>
  120. </Grid>
  121. <TextBox Grid.Row="1" Margin="0,0,0,10" Width="180" Height="32" HorizontalAlignment="Center"
  122. Text="{Binding SearchContent,Mode=TwoWay}"
  123. />
  124. <Grid Grid.Row="2" Margin="10,0,10,0" Visibility="{Binding IsEmpty ,Converter={StaticResource InvertBoolToVisibleConvert}}">
  125. <TextBlock Margin="0,0,0,10" Text="All Result" VerticalAlignment="Center" HorizontalAlignment="Left"/>
  126. <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
  127. <TextBlock Margin="0,0,0,10" Text="Results:" VerticalAlignment="Center" HorizontalAlignment="Right"/>
  128. <TextBlock x:Name="TbCount" Margin="0,0,0,10" Text="{Binding SearchCount}" VerticalAlignment="Center" HorizontalAlignment="Right"/>
  129. </StackPanel>
  130. </Grid>
  131. <Grid Grid.Row="3">
  132. <ListView Name="SearchResultList" VirtualizingPanel.IsVirtualizingWhenGrouping="True"
  133. ItemsSource="{Binding searchResults,Mode=OneWay}"
  134. BorderThickness="0" ItemContainerStyle="{StaticResource ListViewItemGraySelectStyle}"
  135. Visibility="{Binding IsEmpty ,Converter={StaticResource InvertBoolToVisibleConvert}}"
  136. SelectionChanged="SearchResultList_SelectionChanged"
  137. ScrollViewer.HorizontalScrollBarVisibility="Hidden">
  138. <ListView.GroupStyle>
  139. <GroupStyle>
  140. <GroupStyle.HeaderTemplate>
  141. <DataTemplate>
  142. <Grid Background="#E2E3E6" Height="24" >
  143. <TextBlock Padding="0,4,12,4" VerticalAlignment="Stretch" TextAlignment="Center" HorizontalAlignment="Center" FontWeight="SemiBold" FontSize="12" Text="{Binding Name}"
  144. FontFamily="Segoe UI" Foreground="#666666 "/>
  145. <customControl:CustomIconToggleBtn x:Name="BtnExptend" Height="24" Click="BtnExptend_Click"
  146. HorizontalAlignment="Right"
  147. Style="{StaticResource ToggleBtnViewModeStyle}">
  148. <TextBlock Text="展开" VerticalAlignment="Center"/>
  149. </customControl:CustomIconToggleBtn>
  150. </Grid>
  151. </DataTemplate>
  152. </GroupStyle.HeaderTemplate>
  153. <GroupStyle.Panel>
  154. <ItemsPanelTemplate>
  155. <VirtualizingStackPanel/>
  156. </ItemsPanelTemplate>
  157. </GroupStyle.Panel>
  158. </GroupStyle>
  159. </ListView.GroupStyle>
  160. <ListView.ItemsPanel>
  161. <ItemsPanelTemplate>
  162. <VirtualizingStackPanel Background="White" Margin="-5,0,0,0"></VirtualizingStackPanel>
  163. </ItemsPanelTemplate>
  164. </ListView.ItemsPanel>
  165. <ListView.ItemTemplate>
  166. <ItemContainerTemplate>
  167. <StackPanel>
  168. <RichTextBox Background="Transparent" Foreground="#000000" FontFamily="Segoe UI" FontSize="14" IsReadOnly="True" BorderThickness="0"
  169. Padding="12,6,10,6" VerticalContentAlignment="Center" VerticalAlignment="Center"
  170. helper:RichTextBoxHelper.DocumentBind="{Binding BindProperty}"
  171. Width="{Binding ElementName=SearchResultList,Path=ActualWidth,Converter={StaticResource WidthConvert}}"
  172. IsHitTestVisible="False" >
  173. </RichTextBox>
  174. </StackPanel>
  175. </ItemContainerTemplate>
  176. </ListView.ItemTemplate>
  177. <i:Interaction.Triggers>
  178. <i:EventTrigger EventName="SelectionChanged">
  179. <i:InvokeCommandAction Command="{Binding SearchChangedCommand}" CommandParameter="{Binding ElementName=SearchResultList,Path=SelectedItem}"/>
  180. </i:EventTrigger>
  181. </i:Interaction.Triggers>
  182. </ListView>
  183. </Grid>
  184. <Grid Grid.Row="0" Grid.RowSpan="4" Visibility="{Binding IsEmpty ,Converter={StaticResource BoolToVisible}}">
  185. <StackPanel VerticalAlignment="Center" >
  186. <Rectangle Margin="0,0,0,10" Width="140" Height="140" Fill="#D9D9D9" />
  187. <TextBlock Text="Clik the XXX button below to create a XXX" Foreground="#94989C" Width="180" FontFamily="SF Pro Text" LineHeight="22" FontSize="14" TextAlignment="Center" TextWrapping="Wrap"/>
  188. </StackPanel>
  189. </Grid>
  190. </Grid>
  191. </UserControl>