Skip to content

Commit

Permalink
Implement styles for SelectableTextBlock. Fix #243. #234
Browse files Browse the repository at this point in the history
  • Loading branch information
SKProCH committed Jun 7, 2023
1 parent d72028b commit 0d3b10b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions Material.Styles/MaterialToolKit.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<ResourceInclude Source="avares://Material.Styles/Resources/Themes/NavigationDrawer.axaml" />

<ResourceInclude Source="avares://Material.Styles/Resources/Themes/Scroller.axaml" />
<ResourceInclude Source="avares://Material.Styles/Resources/Themes/SelectableTextBlock.axaml" />
<ResourceInclude Source="avares://Material.Styles/Resources/Themes/Separator.axaml" />
<ResourceInclude Source="avares://Material.Styles/Resources/Themes/SplitView.axaml" />

Expand Down
22 changes: 22 additions & 0 deletions Material.Styles/Resources/Themes/SelectableTextBlock.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<SelectableTextBlock Text="Preview" />
</Design.PreviewWith>

<MenuFlyout x:Key="SelectableTextBlockContextFlyout" Placement="Bottom">
<MenuItem x:Name="SelectableTextBlockContextFlyoutCopyItem" Header="Copy"
Command="{Binding $parent[SelectableTextBlock].Copy}"
IsEnabled="{Binding $parent[SelectableTextBlock].CanCopy}" InputGesture="{x:Static TextBox.CopyGesture}" />
</MenuFlyout>

<ControlTheme x:Key="{x:Type SelectableTextBlock}" TargetType="SelectableTextBlock">
<Setter Property="SelectionBrush" Value="{DynamicResource PrimaryHueMidBrush}" />

<Style Selector="^[IsEnabled=True]">
<Setter Property="Cursor" Value="IBeam" />
<Setter Property="ContextFlyout" Value="{StaticResource SelectableTextBlockContextFlyout}" />
</Style>
</ControlTheme>
</ResourceDictionary>

0 comments on commit 0d3b10b

Please sign in to comment.