Vb.net Silverlight-将网格连接到画布进行打印后的屏幕空白
所以,为了打印我的Silverlight网格,我必须将它们从LayoutRoot和Children中删除。将它们添加到我用于打印的画布中。(因为它们一次只能附着到一个父元素) 这很好,但这会留下我的屏幕空白,因为网格已从LayoutRoot中移除 所以我尝试了Children。从画布中删除和Children。添加回LayoutRoot,但它不会将任何内容添加回屏幕 我该如何处理这件事?谢谢 (使用Silverlght 5和VB.net) 我的代码:Vb.net Silverlight-将网格连接到画布进行打印后的屏幕空白,vb.net,silverlight,silverlight-5.0,Vb.net,Silverlight,Silverlight 5.0,所以,为了打印我的Silverlight网格,我必须将它们从LayoutRoot和Children中删除。将它们添加到我用于打印的画布中。(因为它们一次只能附着到一个父元素) 这很好,但这会留下我的屏幕空白,因为网格已从LayoutRoot中移除 所以我尝试了Children。从画布中删除和Children。添加回LayoutRoot,但它不会将任何内容添加回屏幕 我该如何处理这件事?谢谢 (使用Silverlght 5和VB.net) 我的代码: If PageCounter = 1 Then
If PageCounter = 1 Then
Dim PrintSurface As New Canvas
Dim topPosition1 As Double = e.PageMargins.Top + 10
Dim topPosition2 As Double = e.PageMargins.Top + 600
CompChartGrid.SetValue(Canvas.TopProperty, topPosition1)
AttChartGrid.SetValue(Canvas.TopProperty, topPosition2)
LayoutRoot.Children.Remove(CompChartGrid)
PrintSurface.Children.Add(CompChartGrid)
LayoutRoot.Children.Remove(AttChartGrid)
PrintSurface.Children.Add(AttChartGrid)
e.PageVisual = PrintSurface
PrintSurface.Children.Remove(CompChartGrid)
PrintSurface.Children.Remove(AttChartGrid)
LayoutRoot.Children.Add(CompChartGrid)
LayoutRoot.Children.Add(AttChartGrid)
PageCounter += 1
e.HasMorePages = True
Exit Sub
End If
这很可能是由于剪辑。 当您在元素上设置Canvas.Top属性时,该值将一直保持,直到被替换为止。因此,将CompChartGrid和AttChartGrid添加回LayoutRoot网格时,它们分别被topPosition1和topPosition2偏移 试着打电话
CompChartGrid.ClearValue(Canvas.TopProperty)
及
然后元素应该回到它们开始的地方。在添加所有子元素之后,可能会调用LayoutRoot.UpdateLayout()?
AttChartGrid.ClearValue(Canvas.TopProperty)