Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 带内联线的可编辑文本控件?_C#_Wpf - Fatal编程技术网

C# 带内联线的可编辑文本控件?

C# 带内联线的可编辑文本控件?,c#,wpf,C#,Wpf,使用TextBlock可以对格式化文本使用内联线,例如,每个文本部分使用不同的背景色。但是TextBlock是不可编辑的 WPF是否提供一个可编辑文本控件,其中包含格式化文本的内联线?您可能正在寻找该控件: 我是红色的 我是绿色的 如果您想以编程方式对其进行更改,您可能想看看这个 或者,作为一个更好的解决方案,您可以将背景绑定到模型数据,并使用一些自定义设置 我是红色的 <RichTextBox> <FlowDocument> <Par

使用
TextBlock
可以对格式化文本使用内联线,例如,每个文本部分使用不同的背景色。但是
TextBlock
是不可编辑的


WPF是否提供一个可编辑文本控件,其中包含格式化文本的内联线?

您可能正在寻找该控件:


我是红色的
我是绿色的
如果您想以编程方式对其进行更改,您可能想看看这个

或者,作为一个更好的解决方案,您可以将背景绑定到模型数据,并使用一些自定义设置

我是红色的
<RichTextBox>
    <FlowDocument>
        <Paragraph>
             <Run Background="Red"> I am red </Run>
             <Run Background="Green">And I am green</Run>
        </Paragraph>
    </FlowDocument>
</RichTextBox>
<Run Background="{Binding ColorDeterminingProp, Converter={StaticResource myConverterInstance}}"> I am red </Run>