Wpf: Text selection for TextBlock

Created on 31 Jan 2019  路  3Comments  路  Source: dotnet/wpf


This feature is already exist in UWP, can it port to WPF?

issue-type-design-discussion issue-type-enhancement

Most helpful comment

AFAIK the code bases are vastly different, so "porting" means writing it from scratch ... just FYI.

All 3 comments

AFAIK the code bases are vastly different, so "porting" means writing it from scratch ... just FYI.

Related: SO discussion

@vatsan-madhavan
But HorizontalAlignment does not work for RichTextBox, even the text is very short.

<TextBlock HorizontalAlignment="Right">
</TextBlock><!-- of course, this is ok -->

```XAML
HorizontalAlignment="Right">

In my project, I'm using this way to solve.
```XAML
<Grid HorizontalAlignment="Right">
    <TextBlock x:Name="TextBlock"
               IsHitTestVisible="False"
               Opacity="0"
               TextWrapping="Wrap" />
    <RichTextBox Width="{Binding Element=TextBlock, Path=ActualWidth}"
                 IsReadOnly="True" />
</Grid>

But I think it is too complex, I hope it will be simpler.

Was this page helpful?
0 / 5 - 0 ratings