本文整理汇总了C#中System.Windows.Controls.DataGrid.Measure方法的典型用法代码示例。如果您正苦于以下问题:C# DataGrid.Measure方法的具体用法?C# DataGrid.Measure怎么用?C# DataGrid.Measure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.DataGrid
的用法示例。
在下文中一共展示了DataGrid.Measure方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: print
public static void print(DataGrid grid)
{
// FlowDocument doc = new FlowDocument();
//FixedDocument fixedDoc = new FixedDocument();
//PageContent pageContent = new PageContent();
//FixedPage fixedPage = new FixedPage();
//fixedPage.Children.Add(grid);
//((System.Windows.Markup.IAddChild)pageContent).AddChild(fixedPage);
//fixedDoc.Pages.Add(pageContent);
//PrintWindow pWin = new PrintWindow();
//pWin.SetDoc(fixedDoc);
//pWin.ShowDialog();
PrintDialog pDialog = new PrintDialog();
pDialog.PageRangeSelection = PageRangeSelection.AllPages;
pDialog.UserPageRangeEnabled = true;
double HorizontalOffset = 20;
double VerticalOffset = 20;
double oriHeight = grid.Height;
double oriWidth = grid.Width;
grid.Height = Double.NaN;
if (grid.Width > pDialog.PrintableAreaWidth - HorizontalOffset)
{
grid.Width = pDialog.PrintableAreaWidth - HorizontalOffset;
}
grid.UpdateLayout();
Nullable<Boolean> print = pDialog.ShowDialog();
if (print == true)
{
string title = "KimWorks-SalonManager";
grid.Measure(new Size(Double.PositiveInfinity,Double.PositiveInfinity));
Size sizeGrid = grid.DesiredSize;
Point ptGrid = new Point(HorizontalOffset, VerticalOffset);
grid.Arrange(new Rect(ptGrid, sizeGrid));
pDialog.PrintVisual(grid, title);
double diff;
int i = 1;
while ((diff = sizeGrid.Height - (pDialog.PrintableAreaHeight - VerticalOffset) * i) > 0)
{
//Position of the grid
var ptSecondGrid = new Point(HorizontalOffset, -sizeGrid.Height + diff + VerticalOffset);
// Layout of the grid
grid.Arrange(new Rect(ptSecondGrid, sizeGrid));
//print
int k = i + 1;
pDialog.PrintVisual(grid, title + " (Page " + k + ")");
i++;
}
//Size pageSize = new Size(pDialog.PrintableAreaWidth, pDialog.PrintableAreaHeight);
//grid.Measure(pageSize);
//grid.Arrange(new Rect(5,5,pageSize.Width,pageSize.Width));
//pDialog.PrintVisual(grid, "KimWorks-SalonManager");
}
grid.Height = oriHeight;
grid.Width = oriWidth;
grid.UpdateLayout();
}