wpf中textbox换行解决方法

2017-08-02 22:38:02来源:CSDN作者:wow3065人点击

分享
<TextBox HorizontalAlignment="Left" Height="76" Margin="0,378,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="483" Text="{Binding test,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" AcceptsReturn="True">
       <TextBox.InputBindings>
             <KeyBinding Key="Return" Modifiers="Shift"></KeyBinding>
             <KeyBinding Key="Return" Command="{Binding command}"></KeyBinding>
       </TextBox.InputBindings>

</TextBox>

换行设置AcceptsReturn="True"

AcceptsReturn的默认响应key为回车键(Enter),如果想改成其他键盘如下设置

<TextBox.InputBindings>
     <KeyBinding Key="Return" Modifiers="Shift"></KeyBinding>    改成shift+enter
     <KeyBinding Key="Return" Command="{Binding command}"></KeyBinding>  enter触发后台方法.command为后台binding方法(一定要加上红色字体)。
</TextBox.InputBindings>

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台