zoukankan      html  css  js  c++  java
  • Silverlight打印解决方案2.0之如何自定义表体

    通常我们的表体都是二维表格形式的,正如 Silverlight打印解决方案2.0 Demo 中演示的那样绑定就好了。那如果我要自定义表体怎么办呢?

    大体代码是这样的:

    1、Xaml:

     <local:Report x:Name="Report3" Title="自定义表体">
                        <local:Report.PageHeaderTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Title}" FontSize="16" FontWeight="Bold" HorizontalAlignment="Center"/>
                            </DataTemplate>
                        </local:Report.PageHeaderTemplate>

                        <local:Report.ItemTemplate>
                            <DataTemplate>
                                <Grid Height="120" Margin="10">
                                    <Rectangle Stroke="Gray" StrokeThickness="1"/>
                                    <StackPanel>
                                        <TextBlock Text="{Binding Customer.Name}" Margin="4"/>
                                        <TextBlock Text="{Binding Product.Name}" Margin="4"/>
                                    </StackPanel>
                                </Grid>
                            </DataTemplate>
                        </local:Report.ItemTemplate>

                        <local:Report.PageFooterTemplate>
                            <DataTemplate>
                                <Grid>

                                    <StackPanel Orientation="Horizontal"
                                        HorizontalAlignment
    ="Right"
                                        VerticalAlignment
    ="Center"
                                        Margin
    ="5">
                                        <TextBlock Text="{Binding CurrentPageNumber}" />
                                        <TextBlock Text="{Binding TotalPageCount, StringFormat='/{0}'}" />

                                    </StackPanel>
                                </Grid>
                            </DataTemplate>
                        </local:Report.PageFooterTemplate>
                    </local:Report>

    2、cs: 

    private void Button4_Click(object sender, RoutedEventArgs e)
            {
                var tag = new TagData();
                tag.Total = data.Sum(r => r.Sum);
                tag.Count = data.Count;

                Report3.DefaultPageSize = PageSizes.B5;
                Report3.ItemsSource = data;
                Report3.TagData = tag;
                Report3.Preview();
            }

    生成的报表是这个样子:

  • 相关阅读:
    MacOS中Elasticsearch的安装「借助Homebrew」
    全文搜索Lucene之倒排索引
    MybatisCodeHelperNew-2.8.1-191-201插件使用
    支付宝支付-当面付之扫码支付「扫码支付」
    ConcurrentHashMap底层原理?
    支付宝手机h5网页支付不再提供「继续浏览器付款」按钮了吗
    小程序json字符串取值问题,怎么取出来的是undefined,eval函数不能用?
    @SpringBootApplication(exclude={DataSourceAutoConfiguration.class})注解作用
    CAS无锁机制
    数组追加数组,小程序数组里面追加数组如何操作?
  • 原文地址:https://www.cnblogs.com/slmk/p/2524712.html
Copyright © 2011-2022 走看看