} // default constructor cannot be used //https://msdn.microsoft.com/en-us/library/ms752271%28v=vs.100%29.aspx public static GridToPrint Create() { GridToPrint ret = new GridToPrint(); // ret.Background = new SolidColorBrush(Colors.PaleVioletRed); // Define the Columns ColumnDefinition colDef1 = new ColumnDefinition(); ColumnDefinition colDef2 = new ColumnDefinition(); ColumnDefinition colDef3 = new ColumnDefinition(); colDef1.Width = new GridLength(100); colDef2.Width = new GridLength(1, GridUnitType.Star);// GridLength.Auto; colDef3.Width = new GridLength(100); ret.ColumnDefinitions.Add(colDef1); ret.ColumnDefinitions.Add(colDef2); ret.ColumnDefinitions.Add(colDef3); // Define the Rows RowDefinition rowDef1 = new RowDefinition(); RowDefinition rowDef2 = new RowDefinition(); RowDefinition rowDef3 = new RowDefinition(); rowDef1.Height = new GridLength(100); rowDef2.Height = new GridLength(1, GridUnitType.Star); rowDef3.Height = new GridLength(100); ret.RowDefinitions.Add(rowDef1); ret.RowDefinitions.Add(rowDef2); ret.RowDefinitions.Add(rowDef3); ret.ShowGridLines = false; return(ret); }
public GridToPrint GetGridToPrint(int PageNumber) { GridToPrint gtp; gtp = GridToPrint.Create(); gtp.Width = this.size.Width; gtp.Height = this.size.Height; DataGrid content = GetContent(PageNumber); gtp.SetContent(content); // Size the Grid. gtp.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); Size sizeGrid = gtp.DesiredSize; // Determine point for centering Grid on page. Point ptGrid = new Point((this.size.Width - sizeGrid.Width) / 2, (this.size.Height - sizeGrid.Height) / 2); // Layout pass. gtp.Arrange(new Rect(ptGrid, sizeGrid)); return(gtp); }
public void Test2(DataGrid x) { Size S = new Size(793, 1122); GridDocumentPaginator paginator = new GridDocumentPaginator(x, S); GridToPrint gPrint; gPrint = paginator.GetGridToPrint(0); GridToPrint.SetUIElementOnGrid(this.gridMain, 0, 0, gPrint); }
public void Test1() { GridToPrint gPrint = GridToPrint.Create(); GridToPrint.SetUIElementOnGrid(this.gridMain, 0, 0, gPrint); Button btn2 = new Button(); btn2.Content = "btn2"; gPrint.SetContent(btn2); }