Click here to Skip to main content
12,397,102 members (68,120 online)
Click here to Skip to main content

Stats

40.1K views
3.5K downloads
23 bookmarked
Posted

Custom Data Grid Document Paginator

, 20 Dec 2010 CPOL
This article describes how to create your own custom data grid document paginator.
<Window x:Class="CustomDocumentPaginator.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow"
        Height="350"
        Width="525">
    <Grid>

        <Grid Margin="5">

            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <DataGrid x:Name="wpfDataGrid"
                      ItemsSource="{Binding People}"
                      AutoGenerateColumns="False">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Name"
                                        Binding="{Binding Name}" />

                    <DataGridTextColumn Header="Address"
                                        Binding="{Binding Name}" />

                    <DataGridTemplateColumn Header="Happy">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock x:Name="FieldValue"
                                           Foreground="Red"
                                           FontWeight="Bold"
                                           Text="No" />
                                <DataTemplate.Triggers>
                                    <DataTrigger Binding="{Binding Happy}"
                                                 Value="true">
                                        <Setter TargetName="FieldValue"
                                                Property="Text"
                                                Value="Yes" />
                                        <Setter TargetName="FieldValue"
                                                Property="Foreground"
                                                Value="Black" />
                                        <Setter TargetName="FieldValue"
                                                Property="FontWeight"
                                                Value="Normal" />
                                    </DataTrigger>
                                </DataTemplate.Triggers>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                </DataGrid.Columns>

            </DataGrid>

            <Button Grid.Row="1"
                    Command="{Binding PrintCommand}"
                    CommandParameter="{Binding ElementName=wpfDataGrid}"
                    Margin="0,5,0,0"
                    Width="50"
                    Height="25"
                    Content="Print"
                    HorizontalAlignment="Right" />

        </Grid>

    </Grid>
</Window>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Chris L Mullin
Technical Lead System C Healthcare
United Kingdom United Kingdom
Good all rounder (I like to say) with over 12 years development experience in a range languages including Visual C++ , Visual Basic 4/5/6, and now my main area of focus C#.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160721.1 | Last Updated 20 Dec 2010
Article Copyright 2010 by Chris L Mullin
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid