【问题标题】:WPF, Canvas, FormattedText.BuildGeometry - why is nothing displayed?WPF、Canvas、FormattedText.BuildGeometry - 为什么什么都不显示?
【发布时间】:2011-01-05 19:38:33
【问题描述】:

我需要显示与几何混合的文本 - 到目前为止,我的几何显示很好(从下面的示例中删除),但文本根本没有显示。

我在下面找到了格式化文本的示例,并认为我应该能够获取 buildGeometry 并将其包含在要在画布中显示的路径中。

谁能帮我看看我做错了什么?

感谢您的任何回复,

安德斯,丹麦

        var canvas = new Canvas();
        var formattedText = new FormattedText(
            "Hello world",
            CultureInfo.GetCultureInfo("en-us"),
            FlowDirection.LeftToRight,
            new Typeface("Verdana"),
            32,
            Brushes.Black);
        var buildGeometry = formattedText.BuildGeometry(new Point(500, 500));
        var path = new System.Windows.Shapes.Path();
        path.Data = buildGeometry;
        canvas.Children.Add(path);

        Content = canvas;

【问题讨论】:

    标签: wpf path canvas geometry


    【解决方案1】:

    好卡兰巴,

    Path 需要定义一个 Stroke 才能显示任何内容(!)。

    向所有花时间在我的问题上的人道歉......

            var path = new System.Windows.Shapes.Path
            {
                Stroke = Brushes.Black,
                StrokeThickness = 1
            };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多