1. 思想:
使用GridSplitter加到结构中,作为控件。
2. Xaml代码:
- <Window
- x:Class="TestWPF_Func1207.TestRichTextBox"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:VM="clr-namespace:TestWPF_Func1207.ViewModel"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="clr-namespace:TestWPF_Func1207"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- Title="TestRichTextBox"
- Width="500"
- Height="250"
- d:DataContext="{d:DesignInstance Type=VM:TestRichTextBoxViewModel}"
- Background="#F0F8FF"
- mc:Ignorable="d">
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="150" />
- <ColumnDefinition Width="Auto" />
- <ColumnDefinition Width="1*" />
- </Grid.ColumnDefinitions>
- <StackPanel Margin="10,10,10,10" Orientation="Vertical">
- <Button
- Width="Auto"
- Margin="0,10,0,0"
- Click="Button_Click"
- Content="ShowExpression"
- Style="{StaticResource BtnStyle_S}" />
- </StackPanel>
-
- <!--拖拽的分割线-->
- <GridSplitter
- Grid.Column="1"
- Width="3"
- HorizontalAlignment="Center"
- Background="Orange"
- ShowsPreview="True" />
- <StackPanel Grid.Column="2" Grid.ColumnSpan="2">
- <RichTextBox
- x:Name="RichTxt"
- Height="60"
- Margin="10"
- AcceptsReturn="True"
- AutoWordSelection="True"
- CaretBrush="OrangeRed"
- InputMethod.IsInputMethodEnabled="False"
- SpellCheck.IsEnabled="True"
- VerticalScrollBarVisibility="Auto">
- <FlowDocument>
- <Paragraph x:Name="_paragraph" Margin="2" />
- </FlowDocument>
- </RichTextBox>
- </StackPanel>
- </Grid>
- </Window>
复制代码
3. 效果:
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |