无法在 WPF 中编辑 Textblock 内容

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14599449/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 23:39:36  来源:igfitidea点击:

Can't edit Textblock content in WPF

wpfxamltextblock

提问by Ortund

I'm working on my first WPF application and I notice that I'm not able to edit the text values in any of my textblocks.

我正在开发我的第一个 WPF 应用程序,但我注意到我无法编辑任何文本块中的文本值。

I can't seem to find anything wrong here that would prevent me from changing it...

我似乎在这里找不到任何会阻止我更改它的错误...

<Label Content="Line Terminator" Grid.Row="0" Grid.Column="0" Margin="5"></Label>
<Border BorderThickness="1" BorderBrush="LightBlue" Grid.Row="0" Grid.Column="1" Margin="5">
    <TextBlock x:Name="txtLineTerm" Focusable="True" IsManipulationEnabled="True" Padding="3"></TextBlock>
</Border>
<Label Content="Field Terminator" Grid.Row="0" Grid.Column="2" Margin="5"></Label>
<Border BorderThickness="1" BorderBrush="LightBlue" Grid.Row="0" Grid.Column="3" Margin="5">
    <TextBlock x:Name="txtFieldTerm" Focusable="True" IsManipulationEnabled="True" Padding="3"></TextBlock>
</Border>

Can anyone see the problem? I feel like there's a concept that I'm missing here. Any explanation will be greatly appreciated.

任何人都可以看到问题吗?我觉得这里缺少一个概念。任何解释将不胜感激。

回答by Memoizer

TextBlock is not editable. Use TextBox instead.

TextBlock 不可编辑。改用文本框。

回答by Vikram

you can use EditableTextBlockas shown in the link

您可以使用EditableTextBlock如链接所示