SearchContent.xaml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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:i="http://schemas.microsoft.com/xaml/behaviors"
  14. mc:Ignorable="d"
  15. d:DesignHeight="450" d:DesignWidth="800">
  16. <UserControl.Resources>
  17. <convert:WidthConvert x:Key="WidthConvert"/>
  18. <Style x:Key="ListViewItemGraySelectStyle" TargetType="{x:Type ListViewItem}">
  19. <Setter Property="UIElement.SnapsToDevicePixels"
  20. Value="True" />
  21. <Setter Property="Control.Padding"
  22. Value="4,1" />
  23. <Setter Property="Control.HorizontalContentAlignment">
  24. <Setter.Value>
  25. <Binding Path="HorizontalContentAlignment"
  26. RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ItemsControl, AncestorLevel=1}" />
  27. </Setter.Value>
  28. </Setter>
  29. <Setter Property="Control.VerticalContentAlignment">
  30. <Setter.Value>
  31. <Binding Path="VerticalContentAlignment"
  32. RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ItemsControl, AncestorLevel=1}" />
  33. </Setter.Value>
  34. </Setter>
  35. <Setter Property="Panel.Background"
  36. Value="#00FFFFFF" />
  37. <Setter Property="Border.BorderBrush"
  38. Value="#00FFFFFF" />
  39. <Setter Property="Border.BorderThickness"
  40. Value="1" />
  41. <Setter Property="FrameworkElement.FocusVisualStyle">
  42. <Setter.Value>
  43. <Style TargetType="{x:Type IFrameworkInputElement}">
  44. <Setter Property="Control.Template">
  45. <Setter.Value>
  46. <ControlTemplate>
  47. <Rectangle Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
  48. StrokeThickness="1"
  49. StrokeDashArray="1 2"
  50. Margin="2"
  51. SnapsToDevicePixels="True" />
  52. </ControlTemplate>
  53. </Setter.Value>
  54. </Setter>
  55. </Style>
  56. </Setter.Value>
  57. </Setter>
  58. <Setter Property="Control.Template">
  59. <Setter.Value>
  60. <ControlTemplate TargetType="{x:Type ListViewItem}">
  61. <Border BorderThickness="{TemplateBinding Border.BorderThickness}"
  62. Padding="{TemplateBinding Control.Padding}"
  63. BorderBrush="{TemplateBinding Border.BorderBrush}"
  64. Background="{TemplateBinding Panel.Background}"
  65. Name="Bd"
  66. SnapsToDevicePixels="True">
  67. <ContentPresenter Content="{TemplateBinding ContentControl.Content}"
  68. ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
  69. ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}"
  70. HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
  71. VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
  72. SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
  73. </Border>
  74. <ControlTemplate.Triggers>
  75. <MultiTrigger>
  76. <MultiTrigger.Conditions>
  77. <Condition Property="UIElement.IsMouseOver" Value="True" />
  78. </MultiTrigger.Conditions>
  79. <Setter Property="Panel.Background" TargetName="Bd" Value="#1A000000" />
  80. <Setter Property="Border.BorderBrush" TargetName="Bd" Value="#1A000000" />
  81. </MultiTrigger>
  82. <MultiTrigger>
  83. <MultiTrigger.Conditions>
  84. <Condition Property="Selector.IsSelectionActive" Value="False" />
  85. <Condition Property="Selector.IsSelected" Value="True" />
  86. </MultiTrigger.Conditions>
  87. <Setter Property="Panel.Background" TargetName="Bd" Value="#1A477EDE" />
  88. <Setter Property="Border.BorderBrush" TargetName="Bd" Value="#1A477EDE" />
  89. </MultiTrigger>
  90. <MultiTrigger>
  91. <MultiTrigger.Conditions>
  92. <Condition Property="Selector.IsSelectionActive" Value="True" />
  93. <Condition Property="Selector.IsSelected" Value="True" />
  94. </MultiTrigger.Conditions>
  95. <Setter Property="Panel.Background" TargetName="Bd" Value="#1A477EDE" />
  96. <Setter Property="Border.BorderBrush" TargetName="Bd" Value="#1A477EDE" />
  97. </MultiTrigger>
  98. <Trigger Property="UIElement.IsEnabled" Value="False">
  99. <Setter Property="TextElement.Foreground" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
  100. </Trigger>
  101. </ControlTemplate.Triggers>
  102. </ControlTemplate>
  103. </Setter.Value>
  104. </Setter>
  105. </Style>
  106. </UserControl.Resources>
  107. <Grid Background="#F3F3F3" Width="200">
  108. <Grid.RowDefinitions>
  109. <RowDefinition Height="auto"/>
  110. <RowDefinition Height="auto"/>
  111. <RowDefinition/>
  112. </Grid.RowDefinitions>
  113. <Grid Height="48" >
  114. <TextBlock Text="查找" HorizontalAlignment="Left" VerticalAlignment="Center"/>
  115. <Button Content="完成" HorizontalAlignment="Right" VerticalAlignment="Center"/>
  116. </Grid>
  117. <Grid Height="48" Grid.Row="1">
  118. <TextBox Width="150" HorizontalAlignment="Left"/>
  119. <Button Content="完成" HorizontalAlignment="Right" VerticalAlignment="Center" Command="{Binding SearchTextCommand}"/>
  120. </Grid>
  121. <Grid Grid.Row="2">
  122. <ListView Grid.Row="1" Name="SearchResultList" VirtualizingPanel.IsVirtualizingWhenGrouping="True"
  123. ItemsSource="{Binding searchResults,Mode=OneWay}"
  124. BorderThickness="0" ItemContainerStyle="{StaticResource ListViewItemGraySelectStyle}"
  125. SelectionChanged="SearchResultList_SelectionChanged"
  126. ScrollViewer.HorizontalScrollBarVisibility="Hidden">
  127. <ListView.GroupStyle>
  128. <GroupStyle>
  129. <GroupStyle.HeaderTemplate>
  130. <DataTemplate>
  131. <StackPanel Background="#E2E3E6" Height="24">
  132. <TextBlock Padding="0,4,12,4" VerticalAlignment="Stretch" TextAlignment="Center" HorizontalAlignment="Right" FontWeight="SemiBold" FontSize="12" Text="{Binding Name}"
  133. FontFamily="Segoe UI" Foreground="#666666 "/>
  134. </StackPanel>
  135. </DataTemplate>
  136. </GroupStyle.HeaderTemplate>
  137. <GroupStyle.Panel>
  138. <ItemsPanelTemplate>
  139. <VirtualizingStackPanel/>
  140. </ItemsPanelTemplate>
  141. </GroupStyle.Panel>
  142. </GroupStyle>
  143. </ListView.GroupStyle>
  144. <ListView.ItemsPanel>
  145. <ItemsPanelTemplate>
  146. <VirtualizingStackPanel Background="White" Margin="-5,0,0,0"></VirtualizingStackPanel>
  147. </ItemsPanelTemplate>
  148. </ListView.ItemsPanel>
  149. <ListView.ItemTemplate>
  150. <ItemContainerTemplate>
  151. <StackPanel>
  152. <RichTextBox Background="Transparent" Foreground="#000000" FontFamily="Segoe UI" FontSize="14" IsReadOnly="True" BorderThickness="0"
  153. Padding="12,6,10,6" VerticalContentAlignment="Center" VerticalAlignment="Center"
  154. helper:RichTextBoxHelper.DocumentBind="{Binding BindProperty}"
  155. Width="{Binding ElementName=SearchResultList,Path=ActualWidth,Converter={StaticResource WidthConvert}}"
  156. IsHitTestVisible="False" >
  157. </RichTextBox>
  158. </StackPanel>
  159. </ItemContainerTemplate>
  160. </ListView.ItemTemplate>
  161. <i:Interaction.Triggers>
  162. <i:EventTrigger EventName="SelectionChanged">
  163. <i:InvokeCommandAction Command="{Binding SearchChangedCommand}" CommandParameter="{Binding ElementName=SearchResultList,Path=SelectedItem}"/>
  164. </i:EventTrigger>
  165. </i:Interaction.Triggers>
  166. </ListView>
  167. </Grid>
  168. </Grid>
  169. </UserControl>