【问题标题】:Can't edit Textblock content in WPF无法在 WPF 中编辑文本块内容
【发布时间】:2013-01-30 08:19:52
【问题描述】:

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

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

<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>

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

【问题讨论】:

  • 您是在问如何在运行时或设计时编辑TextBlock?尽管答案已被接受,但两者都是可能的...... TextBlock 不能 做的是让用户点击它并就地编辑它,就像TextBox

标签: wpf xaml textblock


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    您可以使用EditableTextBlock,如链接所示

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-26
      • 2015-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多