В Windows Community Toolkit .
есть элемент управления
GridSplitter .
Если ваш TextBlock
находится в сетке, вы можете использовать GridSplitter
элемент управления для изменения размера TextBlock с помощью перетаскивания мышью.
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="100"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition MinHeight="100"></RowDefinition>
<RowDefinition Height="11"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock x:Name="txb" Grid.Column="0"
TextWrapping="Wrap"
Margin="12,12" PointerReleased="TextBlock_PointerReleased" PointerPressed="TextBlock_PointerPressed">
This text to simulate the resizing feature of the Grid Splitter Control, try to move the splitter to see the effect RowDefinition MinHeight="100"
</TextBlock>
<controls:GridSplitter
Width="11"
Background="LightGray"
GripperCursor="Default"
HorizontalAlignment="Left"
Grid.Column="1"
ResizeDirection="Auto"
ResizeBehavior="BasedOnAlignment"
CursorBehavior="ChangeOnSplitterHover"
GripperForeground="White">
</controls:GridSplitter>
<controls:GridSplitter
Height="11"
Background="LightGray"
GripperCursor="Default"
HorizontalAlignment="Stretch"
Grid.Row="1"
GripperForeground="White">
</controls:GridSplitter>
</Grid>
Он на самом деле изменяет размеры целевых столбцов или строк, а не изменяет размер TextBlock. Но визуальный эффект совпадает с вашим описанием.
Если вам не нравится этот элемент управления, вам придется реализовать эту функцию самостоятельно. Для вас нет встроенных API.