Windows App SDK WinUI3中RelativePanel内TextBox窗口调整时文本抖动问题
TextBox在RelativePanel中窗口调整时文本抖动问题
将TextBox控件放置在RelativePanel中并使其四边与面板对齐后,调整窗口高度时文本会出现抖动现象。若将TextWrapping属性设置为NoWrap,该问题会消失,但需求是保留文本自动换行且调整窗口时无抖动。
相关XAML代码
<?xml version="1.0" encoding="utf-8"?> <Window x:Class="AcrylicTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:AcrylicTest" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <RelativePanel> <TextBox Visibility="Visible" x:Name="directions" TextWrapping="Wrap" Background="White" Foreground="Black" RelativePanel.AlignRightWithPanel="True" RelativePanel.AlignLeftWithPanel="True" RelativePanel.AlignTopWithPanel="True" RelativePanel.AlignBottomWithPanel="True"> </TextBox> </RelativePanel> </Window>
补充说明
- 该现象属于Windows App SDK的已知Bug,已提交相关Issue。
- 临时解决方案:在窗口调整大小期间隐藏文本,此方案虽不理想,但比文本抖动的体验更好。由于没有原生的窗口调整完成事件,可通过监听Win32事件实现该功能。
内容的提问来源于stack exchange,提问作者user1094779
相关产品推荐
相关产品推荐

