Answer the question
In order to leave comments, you need to log in
WPF. How to print WrapPanel?
It is necessary to send to print (to the printer) WrapPanel with different elements. I created several UserControls and populate them with Children.Add(MyUserControl)
I print with:
var visualsPage = new List<Visual>();
var dialog = new PrintDialog();
if (dialog.ShowDialog() == true)
{
//Подготовка к печати
}
dialog.PrintDocument(new Paginator(visualsPage.ToArray()), "Печать");
for (int i = 0; i < IcBook.Items.Count; i++)
{
page.Add((Visual)IcBook.ItemContainerGenerator.ContainerFromIndex(i));
}
<Grid Name="MainGrid">
<ItemsControl Name="IcBook" ItemsSource="{Binding}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Grid/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<ItemsControl ItemsSource="{Binding LebelList}" Padding="20">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Width="376.5" BorderBrush="Black" BorderThickness="3">
<Grid>
<!--Структура элемента WP-->
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question