• 关于WPF中RichTextBox失去焦点后如何保持高亮显示所选择的内容


    其实很简单,只要将容器控件中的附加属性FocusManager.IsFocusScope设为True就可以了

    下面是个简单的用例:

    <Window x:Class="WpfApplication1.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="30"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <StackPanel Grid.Row="0" Orientation="Horizontal" FocusManager.IsFocusScope="True">
                <ComboBox Width="100">
                    <ComboBoxItem>1</ComboBoxItem>
                    <ComboBoxItem>2</ComboBoxItem>
                    <ComboBoxItem>3</ComboBoxItem>
                </ComboBox>
                <ComboBox Width="100">
                    <ComboBoxItem>a</ComboBoxItem>
                    <ComboBoxItem>b</ComboBoxItem>
                    <ComboBoxItem>c</ComboBoxItem>
                </ComboBox>
            </StackPanel>
            <RichTextBox Grid.Row="1"/>
        </Grid>
    </Window>

     以下是运行效果图

  • 相关阅读:
    msp430入门学习21--TA
    msp430入门学习20
    msp430入门学习17
    msp430入门学习16
    msp430入门学习15--时钟
    msp430入门学习14
    msp430入门学习13
    msp430入门学习12
    msp430入门学习11
    msp430入门学习10
  • 原文地址:https://www.cnblogs.com/guyun/p/4262632.html
Copyright © 2020-2023  润新知