Okra Navigation vs. Stimulsoft Reports for WinRT

Oct 11, 2012 at 4:43 PM

I'm trying to use Stimulsofts Report package (http://www.stimulsoft.com/en/products/reports-winrt)in my WinRT app, and I ran into a hiccup. 

You can view my thread on their forums here: http://forum.stimulsoft.com/viewtopic.php?f=10&t=34998

Basically, I think their Report Viewer setting to integrate buttons with the top and bottom application bar is looking for the current windows content and casting it as a Frame (if they do in their .dll as they did in their example, I don't have the code base). 

From what I can see, your Navigation Framework is setting the Window.Current.Content to the page requested and not using frames at all... is that right?  What can be done to amend this on the Okra side of things, if anything?

Thanks 

Coordinator
Oct 14, 2012 at 8:45 PM

Yes - you are correct that the Okra navigation system doesn't use a Frame as the root element since it handles all navigation requests.

However, I had chance today to download the Stimulsofts Report framework and have a couple of options that look good.

My first suggestion is the one that I would recommend in your case as it will only be a small number of pages that contain the reporting control and hence require the root Frame. Since the Okra [PageExport(...)] attribute can be applied to any type, not just those derived from Page, then you could export a Frame and set the content to the page with the report viewer.

For example, rather than having,

[PageExport("Report")]
public sealed partial class ReportPage : LayoutAwarePage
{
    ...
}

You would remove the [PageExport(...)] attribute from the page and place it on a Frame derived wrapper. In other words,

public sealed partial class ReportPage : LayoutAwarePage
{
    ...
}

[PageExport("Report")]
public class ReportFrame : Frame
{
    public ReportFrame ()
    {
        this.Content = new ReportPage();
    }
}

In my tests this then allows access from the report viewer control to the top and bottom application bars, whilst you can still edit the ReportPage in the designer and Blend since it is still a standard page. Note that if you are using a convention based approach to exporting pages then you would have to name the two classes, ReportPageContent:LayoutAwarePage and ReportPage:Frame instead.

Hope this helps and let me know how you get on,

Andy

Coordinator
Oct 14, 2012 at 8:50 PM
Edited Oct 14, 2012 at 8:51 PM

For reference, my alternative solution takes advantage of Okra's extensibility support for navigation targets. As you have identified the default navigation target is to place the page into a ContentControl as the root element. It is fairly simple to take the default implementation and convert it to use a Frame instead. Since this is composed by MEF all you need to do is to include the following class into your assembly (it will be automatically discovered and replace the default navigation target),

[Export(typeof(INavigationTarget))]
public class FrameNavigationTarget : INavigationTarget
{
    // *** Fields ***

    private Frame contentFrame;

    // *** Methods ***

    public void NavigateTo(object page)
    {
        // If the content host has not been created then create this

        if (contentFrame == null)
        {
            contentFrame = new Frame()
            {
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                VerticalContentAlignment = VerticalAlignment.Stretch
            };
        }

        // Ensure that the window content is set to the content host

        if (Window.Current.Content != contentFrame)
            Window.Current.Content = contentFrame;

        // Set the content to display

        contentFrame.Content = page;
    }
}

Now you can export your pages as usual and they will always be added into a root Frame.

Andy

Oct 16, 2012 at 5:18 PM

I was thinking about doing something like your second option... It works like a charm!

However, for anyone else interested in the Stimulsoft side of things, check a thread here (http://forum.stimulsoft.com/viewtopic.php?f=10&t=35038&sid=eabd5cd2c9c7d3f5e340f4d6b499d578) if you want more info on the Stimulsoft app bar integration.

Coordinator
Oct 16, 2012 at 7:42 PM

Great to hear that this solved your issue.

Andy