building a full trust XBAP app

After reading this post by Karsten, I created a WPF XBAP project that displays the ClassicReports designer on a Frame as shown below.

<Page x:Class="IApp.Page3"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Page3"
    >
    <DockPanel>
        <ToolBarTray DockPanel.Dock="Top">
            <ToolBar>
                <Button Name="newButton">
                    <Image Source="images\new.png" />
                </Button>
                <Button Name="openButton" >
                    <Image Source="images\open.png" />
                </Button>
                <Button  Name="saveButton" >
                    <Image Source="images\save.png" />
                </Button>            
            </ToolBar>
        </ToolBarTray>
        <Frame Name="frame1"></Frame>
    </DockPanel>
</Page>

Below is the c# code behind for the XAML above. Notice that the designer control must first be hosted in a WindowsFormsHost before it can be displayed in WPF. 

namespace IApp
{
    public partial class Page3 : System.Windows.Controls.Page
    {
        JDJ.ClassicReport.ReportDesigner.ReportDesigner designer;

        public Page3()
        {
            InitializeComponent();
            WindowsFormsHost host = new WindowsFormsHost();
            designer = new JDJ.ClassicReport.ReportDesigner.ReportDesigner();
            host.Child = designer;
            frame1.Content = host;
            openButton.Click += new RoutedEventHandler(openButton_Click);
            saveButton.Click += new RoutedEventHandler(saveButton_Click);
            newButton.Click += new RoutedEventHandler(newButton_Click);
        }

        void newButton_Click(object sender, RoutedEventArgs e)
        {
            designer.NewReport();
        }

        void saveButton_Click(object sender, RoutedEventArgs e)
        {
            designer.Save();
        }

        void openButton_Click(object sender, RoutedEventArgs e)
        {
            designer.OpenReport();
        }

    }
}

This is how the above page looks like. Notice the address I used in runnning the XBAP application. That's my actual IP address as of this writing.

XBAP ClassicReports Designer

When I clicked on the Open button the dialog box appears.

XBAP ClassicReports Designer Open File Dialog

So after selecting the Sample Report File, the designer then displays the report layout on the design surface. Now I can modify the report to my heart's content.

XBAP ClassicReports Designer with Sample Report

I almost forgot that I am actually running this rich client application inside a browser! 

Published 10-13-2006 12:22 AM by smash
Filed under: , , , ,