【问题标题】:how to get height width of a stackpanel (with invisible scrolled area)如何获取堆栈面板的高度宽度(带有不可见的滚动区域)
【发布时间】:2012-08-28 20:22:44
【问题描述】:

我正在尝试在 wpf 应用程序中拍摄我的屏幕快照。一切正常,但唯一的问题是,当我需要截取在scrollviewer 的滚动区域中有一些隐藏内容的stakpanel 内容的屏幕截图时,我的代码只获取stackpanel 可见部分的快照。请看下面...

RenderTargetBitmap renderBitmap = 新的渲染目标位图( (int)spMain.ActualWidth, (int)spMain.ActualHeight, 70天, 70天, PixelFormats.Pbgra32);

ActualWidth/ActualHeight 属性仅提供可见部分的高度/宽度。

Q- 我如何获得完整堆栈面板的快照?

谢谢

【问题讨论】:

    标签: wpf c#-4.0


    【解决方案1】:

    我通过在拍摄快照之前测量和排列 UI 元素解决了这个问题。

    spMain.Measure(new Size(spMain.ActualWidth, spMain.ActualHeight)); spMain.Arrange(new Rect(new Size(spMain.ActualWidth, spMain.ActualHeight)));

    :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-25
      • 2014-08-27
      • 2016-10-29
      • 2019-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多