我设法将绑定中的所有数据放入运行中并进行了打印预览,但现在我想制作一个两列的网格。我不知道如何实现它!我设法在段落中制作了网格,就是这样。这是我到目前为止提出的代码:
public Paragraph Par(vwOrderDetailsItem ODI)
{
Grid myGrid = new Grid();
ColumnDefinition colDef1 = new ColumnDefinition();
ColumnDefinition colDef2 = new ColumnDefinition();
myGrid.ColumnDefinitions.Add(colDef1);
myGrid.ColumnDefinitions.Add(colDef2);
RowDefinition rowDef1 = new RowDefinition();
RowDefinition rowDef2 = new RowDefinition();
RowDefinition rowDef3 = new RowDefinition();
RowDefinition rowDef4 = new RowDefinition();
RowDefinition rowDef5 = new RowDefinition();
RowDefinition rowDef6 = new RowDefinition();
RowDefinition rowDef7 = new RowDefinition();
RowDefinition rowDef8 = new RowDefinition();
myGrid.RowDefinitions.Add(rowDef1);
myGrid.RowDefinitions.Add(rowDef2);
myGrid.RowDefinitions.Add(rowDef3);
myGrid.RowDefinitions.Add(rowDef4);
myGrid.RowDefinitions.Add(rowDef5);
myGrid.RowDefinitions.Add(rowDef6);
myGrid.RowDefinitions.Add(rowDef7);
myGrid.RowDefinitions.Add(rowDef8);
Thickness t = new Thickness { Left = 20, Top=100 };
Paragraph p = new Paragraph {Margin = t};
Run r0 = new Run { Text = ODI.Material_AltCode, FontSize = 40};
Run r1 = new Run { Text = ODI.W_Descr, FontSize = 30 };
Run r2 = new Run { Text = ODI.OD_MAT_NAME, FontSize = 20 };
Run r3 = new Run { Text = ODI.ODCO_CODE, FontSize = 20 };
Run r4 = new Run { Text = ODI.OD_q.ToString(), FontSize = 30 };
Run r5 = new Run { Text = ODI.OPT_ITM1, FontSize = 20 };
Run r6 = new Run { Text = ODI.OPT_ITM2 != 0 ? "SX" : "", FontSize = 20 };
Run r7 = new Run { Text = ODI.W_Date.ToString(), FontSize = 20 };
Thickness ti = new Thickness { Top = 50 };
Image imgBC = new Image { Source = (new UWPPrinting.LBLPrint()).GetBC(ODI.Material_AltCode, ZXing.BarcodeFormat.CODE_128, 50, 250), Width = 300, Margin = ti };
InlineUIContainer i = new InlineUIContainer { Child = imgBC };
TextBlock txt1 = new TextBlock();
txt1.Text = r0.ToString();
Grid.SetColumn(txt1, 0);
Grid.SetRow(txt1, 0);
p.Inlines.Add(r0);
p.Inlines.Add(new LineBreak());
p.Inlines.Add(r2);
p.Inlines.Add(new LineBreak());
p.Inlines.Add(r6);
p.Inlines.Add(new LineBreak());
p.Inlines.Add(r3);
p.Inlines.Add(new LineBreak());
p.Inlines.Add(r4);
p.Inlines.Add(new LineBreak());
p.Inlines.Add(r5);
p.Inlines.Add(new LineBreak());
p.Inlines.Add(r1);
p.Inlines.Add(new LineBreak());
p.Inlines.Add(r7);
p.Inlines.Add(new LineBreak());
p.Inlines.Add(i);
return p;
}
dxfhxcgnvxcvbnzdgfgbserdvbtbnasrdm,fgh,sbdakushdfiwisFGIKSHGSA\IKGKLJA\SKXCFGVKADFXKLNAL\KJNDFKLMNAKL;ML;ASDKNVADFSGIOHERIOHJTIOW4HTOIUHERWGTOIRA