CompositeLink Class
A composite link that can be used to combine several Printing Links together into a composite document.
Namespace: DevExpress.Xpf.Printing
Assembly:
DevExpress.Xpf.Printing.v24.1.dll
NuGet Package:
DevExpress.Wpf.Printing
Declaration
public class CompositeLink :
TemplatedLink
Public Class CompositeLink
Inherits TemplatedLink
This code example demonstrates how to use the CompositeLink
class to combine contents of several printing links in a single document.
View Example
Imports System.Collections.Generic
Imports System.Windows
Imports System.Windows.Documents
Imports DevExpress.Xpf.Grid
Imports DevExpress.Xpf.Printing
' ...
Namespace CompositeLinkExample
''' <summary>
''' Interaction logic for MainWindow.xaml
''' </summary>
Partial Public Class MainWindow
Inherits Window
Public Sub New()
InitializeComponent()
End Sub
Private Sub printButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim links As New List(Of TemplatedLink)()
links.Add(New PrintableControlLink(CType(categoriesGrid.View, TableView)))
links.Add(New PrintableControlLink(CType(productsGrid.View, TableView)))
Dim compositeLink As New CompositeLink(links)
PrintHelper.ShowRibbonPrintPreview(Me, compositeLink)
End Sub
End Class
End Namespace
<Window x:Class="CompositeLinkExample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="477" Width="908" xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" xmlns:my="clr-namespace:CompositeLinkExample.nwindDataSetTableAdapters" xmlns:my1="clr-namespace:CompositeLinkExample">
<Window.Resources>
<dx:TypedSimpleSource x:Key="TypedSimpleSource" AdapterType="my:CategoriesTableAdapter" ContextType="my1:nwindDataSet" Path="Categories">
<dx:DesignDataManager.DesignData>
<dx:DesignDataSettings RowCount="5" />
</dx:DesignDataManager.DesignData>
</dx:TypedSimpleSource>
<dx:TypedSimpleSource x:Key="TypedSimpleSource1" AdapterType="my:ProductsTableAdapter" ContextType="my1:nwindDataSet" Path="Products">
<dx:DesignDataManager.DesignData>
<dx:DesignDataSettings RowCount="5" />
</dx:DesignDataManager.DesignData>
</dx:TypedSimpleSource>
</Window.Resources>
<Grid>
<dxg:GridControl AutoGenerateColumns="AddNew" EnableSmartColumnsGeneration="True" HorizontalAlignment="Left" Name="categoriesGrid" VerticalAlignment="Top" Height="188" Width="886" ItemsSource="{Binding Path=Data, Source={StaticResource TypedSimpleSource}}">
<dxg:GridControl.View>
<dxg:TableView AllowPerPixelScrolling="True" Name="tableView1" />
</dxg:GridControl.View>
</dxg:GridControl>
<dxg:GridControl AutoGenerateColumns="AddNew" EnableSmartColumnsGeneration="True" Height="208" HorizontalAlignment="Left" Margin="0,186,0,0" Name="productsGrid" VerticalAlignment="Top" Width="886" ItemsSource="{Binding Path=Data, Source={StaticResource TypedSimpleSource1}}">
<dxg:GridControl.View>
<dxg:TableView AllowPerPixelScrolling="True" Name="tableView2" />
</dxg:GridControl.View>
</dxg:GridControl>
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="762,403,0,0" Name="printButton" VerticalAlignment="Top" Width="112" Click="printButton_Click" />
</Grid>
</Window>
using System.Collections.Generic;
using System.Windows;
using System.Windows.Documents;
using DevExpress.Xpf.Grid;
using DevExpress.Xpf.Printing;
// ...
namespace CompositeLinkExample {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
}
private void printButton_Click(object sender, RoutedEventArgs e) {
List<TemplatedLink> links = new List<TemplatedLink>();
links.Add(new PrintableControlLink((TableView)categoriesGrid.View));
links.Add(new PrintableControlLink((TableView)productsGrid.View));
CompositeLink compositeLink = new CompositeLink(links);
PrintHelper.ShowRibbonPrintPreview(this, compositeLink);
}
}
}
The image below demonstrates the result.
See Also