minor modified code

This commit is contained in:
NaBian committed 2021-09-08 23:03:49 +08:00
1 parent 43c2f67171
commit 07a280ca14
2 files changed
+9 -4

No files matched your search

@@ -49,7 +49,7 @@
<ToggleButton Tag="{Binding ElementName=ListBoxDemo}" Name="ButtonStyleAscending" Click="ButtonAscending_OnClick" Grid.Row="0" Grid.Column="1" Style="{StaticResource DemoInfoSortButtonStyle}"/> <ToggleButton Tag="{Binding ElementName=ListBoxDemo}" Name="ButtonStyleAscending" Click="ButtonAscending_OnClick" Grid.Row="0" Grid.Column="1" Style="{StaticResource DemoInfoSortButtonStyle}"/>
<ListBox Name="ListBoxDemo" ScrollViewer.CanContentScroll="False" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" VirtualizingStackPanel.IsVirtualizing="True" SelectedIndex="{Binding SelectedIndex}" ItemsSource="{Binding DemoItemList}" BorderThickness="0" SelectionMode="Single" Style="{StaticResource ListBoxTransparent}"> <ListBox Name="ListBoxDemo" ScrollViewer.CanContentScroll="False" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" VirtualizingStackPanel.IsVirtualizing="True" SelectedIndex="{Binding SelectedIndex}" ItemsSource="{Binding DemoItemList}" BorderThickness="0" SelectionMode="Single" Style="{StaticResource ListBoxTransparent}">
<ListBox.ItemTemplate> <ListBox.ItemTemplate>
<DataTemplate DataType="data:DemoItemModel"> <DataTemplate>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Image Width="16" Height="16" Source="{Binding ImageName}"/> <Image Width="16" Height="16" Source="{Binding ImageName}"/>
<hc:HighlightTextBlock Margin="6,0,0,0" SourceText="{ex:Lang Key={Binding Name}}" QueriesText="{Binding QueriesText}" HighlightBrush="#f06632" /> <hc:HighlightTextBlock Margin="6,0,0,0" SourceText="{ex:Lang Key={Binding Name}}" QueriesText="{Binding QueriesText}" HighlightBrush="#f06632" />
@@ -13,11 +13,16 @@ namespace HandyControl.Controls
public class HighlightTextBlock : TextBlock public class HighlightTextBlock : TextBlock
{ {
public static readonly DependencyProperty SourceTextProperty = public static readonly DependencyProperty SourceTextProperty =
DependencyProperty.Register("SourceText", typeof(string), typeof(HighlightTextBlock), new PropertyMetadata(null, OnSourceTextChanged)); DependencyProperty.Register("SourceText", typeof(string), typeof(HighlightTextBlock),
new PropertyMetadata(null, OnSourceTextChanged));
public static readonly DependencyProperty QueriesTextProperty = public static readonly DependencyProperty QueriesTextProperty =
DependencyProperty.Register("QueriesText", typeof(string), typeof(HighlightTextBlock), new PropertyMetadata(null, OnQueriesTextChanged)); DependencyProperty.Register("QueriesText", typeof(string), typeof(HighlightTextBlock),
new PropertyMetadata(null, OnQueriesTextChanged));
public static readonly DependencyProperty HighlightBrushProperty = public static readonly DependencyProperty HighlightBrushProperty =
DependencyProperty.Register("HighlightBrush", typeof(Brush), typeof(HighlightTextBlock), new PropertyMetadata(Brushes.Yellow)); DependencyProperty.Register("HighlightBrush", typeof(Brush), typeof(HighlightTextBlock),
new PropertyMetadata(Brushes.Yellow));
private static void OnSourceTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => private static void OnSourceTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) =>
((HighlightTextBlock) d).RefreshInlines(); ((HighlightTextBlock) d).RefreshInlines();