如何在c# WPF后面的代码中为TextBlock设置TextOptions

本文关键字:代码 TextBlock TextOptions 设置 WPF | 更新日期: 2023-09-27 18:09:44

我在WPF后面的代码中添加动态生成的文本块。我需要在代码后面为这个文本块设置以下属性,但我不能这样做:

  • TextOptions。TextFormattingMode = "显示"
  • RenderOptions。BitmapScalingMode = NearestNeighbor"
  • RenderOptions。ClearTypeHint = "启用"

我无法在后面的代码中找到它们或以任何方式找到它们。谁能建议如何在代码中设置这些属性?

如何在c# WPF后面的代码中为TextBlock设置TextOptions

我正在寻找相同的解决方案…在这里:)

在我的情况下,我设置属性为RichTextBox

richTxtEditor.SetValue(TextOptions.TextRenderingModeProperty, TextRenderingMode.Aliased)
richTxtEditor.SetValue(TextOptions.TextRenderingModeProperty, TextRenderingMode.Auto)
richTxtEditor.SetValue(TextOptions.TextRenderingModeProperty, TextRenderingMode.ClearType)
richTxtEditor.SetValue(TextOptions.TextRenderingModeProperty, TextRenderingMode.Grayscale)
richTxtEditor.SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Display)
richTxtEditor.SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Ideal)
richTxtEditor.SetValue(TextOptions.TextHintingModeProperty, TextHintingMode.Animated)
richTxtEditor.SetValue(TextOptions.TextHintingModeProperty, TextHintingMode.Auto)
richTxtEditor.SetValue(TextOptions.TextHintingModeProperty, TextHintingMode.Fixed)