Browse Source

Merge pull request #11364 from AvaloniaUI/fix-selectiontextblock-selectionbrush-color

Use correct theme specific selection brush on SelectableTextBlock
pull/11340/head
Max Katz 3 years ago
committed by GitHub
parent
commit
6277b3e555
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      samples/ControlCatalog/Pages/TextBlockPage.xaml
  2. 2
      src/Avalonia.Controls/SelectableTextBlock.cs
  3. 2
      src/Avalonia.Themes.Fluent/Controls/SelectableTextBlock.xaml
  4. 2
      src/Avalonia.Themes.Simple/Controls/SelectableTextBlock.xaml

2
samples/ControlCatalog/Pages/TextBlockPage.xaml

@ -118,7 +118,7 @@
</StackPanel>
</Border>
<Border>
<SelectableTextBlock SelectionBrush="LightBlue" Margin="10" TextWrapping="Wrap">
<SelectableTextBlock Margin="10" TextWrapping="Wrap">
This <Span FontWeight="Bold">is</Span> a
<Span Background="Silver" Foreground="Maroon">TextBlock</Span>
with <Span TextDecorations="Underline">several</Span>

2
src/Avalonia.Controls/SelectableTextBlock.cs

@ -30,7 +30,7 @@ namespace Avalonia.Controls
o => o.SelectedText);
public static readonly StyledProperty<IBrush?> SelectionBrushProperty =
TextBox.SelectionBrushProperty.AddOwner<SelectableTextBlock>(new(new Data.Optional<IBrush?>(Brushes.Blue)));
TextBox.SelectionBrushProperty.AddOwner<SelectableTextBlock>();
public static readonly DirectProperty<SelectableTextBlock, bool> CanCopyProperty =
TextBox.CanCopyProperty.AddOwner<SelectableTextBlock>(o => o.CanCopy);

2
src/Avalonia.Themes.Fluent/Controls/SelectableTextBlock.xaml

@ -10,6 +10,8 @@
</MenuFlyout>
<ControlTheme x:Key="{x:Type SelectableTextBlock}" TargetType="SelectableTextBlock">
<Setter Property="SelectionBrush" Value="{DynamicResource TextControlSelectionHighlightColor}" />
<Style Selector="^[IsEnabled=True]">
<Setter Property="Cursor" Value="IBeam" />
<Setter Property="ContextFlyout" Value="{StaticResource SelectableTextBlockContextFlyout}" />

2
src/Avalonia.Themes.Simple/Controls/SelectableTextBlock.xaml

@ -10,6 +10,8 @@
</MenuFlyout>
<ControlTheme x:Key="{x:Type SelectableTextBlock}" TargetType="SelectableTextBlock">
<Setter Property="SelectionBrush" Value="{DynamicResource HighlightBrush}" />
<Style Selector="^[IsEnabled=True]">
<Setter Property="Cursor" Value="IBeam" />
<Setter Property="ContextFlyout" Value="{StaticResource SelectableTextBlockContextFlyout}" />

Loading…
Cancel
Save