Skip to content

Commit

Permalink
New sample: Selectable TextBlock (#1578)
Browse files Browse the repository at this point in the history
<!--- Provide a general summary of your changes in the Title above -->

## Description
As title suggest.

## Motivation and Context
Many people are not aware of `TextBlock` is selectable and use `TextBox`
instead which may have higher overhead. So I made this sample.

## How Has This Been Tested?
Mnaual

## Screenshots (if appropriate):

![image](https://github.com/microsoft/WinUI-Gallery/assets/42881734/cf154abe-6700-4b1b-90c0-695096fda9b4)


## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
  • Loading branch information
HO-COOH authored Jul 22, 2024
1 parent e9c9c2d commit f219e4f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions WinUIGallery/ControlPages/TextBlockPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,27 @@
</x:String>
</local:ControlExample.Xaml>
</local:ControlExample>

<local:ControlExample x:Name="Example5" HeaderText="A selectable TextBlock">
<local:ControlExample.Example>
<TextBlock IsTextSelectionEnabled="{x:Bind SelectionEnabledSwitch.IsOn, Mode=OneWay}"
Text="I am a selectable TextBlock with custom SelectionHighlightColor."
SelectionHighlightColor="DarkOrange"/>
</local:ControlExample.Example>

<local:ControlExample.Options>
<ToggleSwitch Header="IsTextSelectionEnabled" x:Name="SelectionEnabledSwitch"/>
</local:ControlExample.Options>
<local:ControlExample.Xaml>
<x:String xml:space="preserve">
&lt;TextBlock IsTextSelectionEnabled="$(IsTextSelectionEnabled)"
Text="I am a selectable TextBlock with custom SelectionHighlightColor."
SelectionHighlightColor="DarkOrange"&gt;
</x:String>
</local:ControlExample.Xaml>
<local:ControlExample.Substitutions>
<local:ControlExampleSubstitution Key="IsTextSelectionEnabled" Value="{x:Bind SelectionEnabledSwitch.IsOn, Mode=OneWay}"/>
</local:ControlExample.Substitutions>
</local:ControlExample>
</StackPanel>
</Page>

0 comments on commit f219e4f

Please sign in to comment.