The Media Center Sandbox

Resources and discussion for developing experiences in the Windows Media Center platform.
Welcome to The Media Center Sandbox Sign in | Join | Help
in Search

NavigateTo PreviousPage in MCML

Last post 03-19-2008, 6:56 AM by EricTsai. 15 replies.
Page 1 of 2 (16 items)   1 2 Next >
Sort Posts: Previous Next
  •  01-15-2007, 6:08 PM 1470

    NavigateTo PreviousPage in MCML

    Hi all,

    Is there a way to go to previous page in MCML?

    It's exactly the same with invoking  "HistoryOrientatedPageSession.BackPage() " from MCML.

    I couldn't find the way to get a reference to HistoryOrientedPageSession instance.

    I'm writing Web Application. So using C# is out of choice.

     

    A Client wants to locate "Back" button on the screen.

    If the button is clicked, the page should go to previous one.

    I don't want to use "Navigate" element because it put the current page on top of the stack.

     

    I hope I could make myself clear.

    Any help is really appreciated.

    Kenichiro,

     

  •  01-15-2007, 11:16 PM 1471 in reply to 1470

    Re: NavigateTo PreviousPage in MCML

    You may be able to add the HistoryOrientedPageSession as an object in your properties section of your MCML, as follows:

    <Mcml xmlns=http://schemas.microsoft.com/2006/mcml
          xmlns:hosting="assembly://Microsoft.MediaCenter/Microsoft.MediaCenter.Hosting"
          
    xmlns:me="Me">

    ...

    <Properties>
       <hosting:HistoryOrientedPageSession Name="Session"/>
    </Properties>

    You can then access it in your MCML - and pass it down through UIs in the properties section.

    Cheers,
    Andrew

     

  •  01-16-2007, 12:43 AM 1473 in reply to 1471

    Re: NavigateTo PreviousPage in MCML

    AndyC, Thank you very much for your response.

    I tried the code below. But it didn't work.
    When I execute FirstPage.mcml from MCMLPad through MediaCenter,
    I received UnhandledAddInException.

    Attempt to build an object of type 'HistoryOrientedPageSession' failed.
    StackTrace:
    Microsoft.MediaCenter.Hosting.PageSession..ctor()
    Microsoft.MediaCenter.Hosting.HistoryOrientedPageSession..ctor()
    ...

    If I execute the page below from MCMLPreviewToolLaucher, I received Fatal Runtime error after I clicked "NextPage".

    Exception: AddInHost cannot be null (InvalidOperationException)
    Stack:
      Microsoft.MediaCenter.Hosting.Infrastructure.McpfState.get_AddInUiHost()
      Microsoft.MediaCenter.Hosting.PageSession.EnsureFullscreenSession()

    Situation is almost the same even if I locate the files on the web server.
    Do I misunderstand something? I'm using Vista(TM) RC1 Build 5600.
    I'm so close to goal. This would be the last problem. But not so much time left. Any help is really appreciated.

    Kenichiro,

    PS:

    I thought that PageSession is kind of runtime environment. And MCML was executed on top of it.

    So I felt uncomfortable to instantiate PageSession object from MCML.

    I might be wrong though.

     

    --FirstPage.mcml--

    <Mcml xmlns="http://schemas.microsoft.com/2006/mcml"
         xmlns:host="assembly://Microsoft.MediaCenter/Microsoft.MediaCenter.Hosting"
       xmlns:me="Me">
     <UI Name="NavigateTest">
      <Properties>
       <host:HistoryOrientedPageSession Name="Session"/>
      </Properties>
      <Locals>
       <ClickHandler Name="Clicker"/>
       <NavigateCommand Name="NavCommand" Source="
    file://NextPage.mcml" Session="[Session]"/>
      </Locals>
      <Rules>
       <Default Target="[Input.KeyInteractive]" Value="true"/>
       <Default Target="[Clicker.Command]" Value="[NavCommand]"/>
      </Rules>
      <Content>
       <Text Content="NextPage" Color="White"/>
      </Content>
     </UI>
    </Mcml>

    --NextPage.mcml--

    <Mcml xmlns="http://schemas.microsoft.com/2006/mcml"
         xmlns:host="assembly://Microsoft.MediaCenter/Microsoft.MediaCenter.Hosting">

     <UI Name="BackPageTest">
      <Locals>
       <ClickHandler Name="Clicker"/>
      </Locals>
      <Properties>
       <host:HistoryOrientedPageSession Name="Session"/>
      </Properties>
      <Rules>
       <Changed Source="[Clicker.Invoked]">
        <Actions>
         <DebugTrace Message="Go to Prev Page (Session.BackPage) Invoke"/>
         <Invoke Target="[Session.BackPage]"/>
        </Actions>
       </Changed>
      </Rules>
      <Content>
       <Text Content="Go to prev page" Color="White"/>
      </Content>
     </UI>
    </Mcml>

  •  01-16-2007, 6:40 AM 1475 in reply to 1473

    Re: NavigateTo PreviousPage in MCML

    Tanaka San,

    First of all, make sure the following is true:

    • You are running on RC2 or later.
    • You are trying your sample outside of Media Center Preview Tool (MCMLPad.exe), as this application does not implement the page stack session yet. You will need to register an entry point for your application in order to do this (see this post for more info).
    Then follow these steps
    • Declare the following XML namespace:
    • xmlns:host="assembly://Microsoft.MediaCenter/Microsoft.MediaCenter.Hosting"
    • Declare the following entry on your properties/locals section  (the name does matter):
    • <host:PageSession Name="Session" PageSession="$Required"/>
    • Invoke the following method where you want the back operation to happen:
    • <Invoke Target="[Session!host:HistoryOrientedPageSession.BackPage]"/>
    Hope this helps!
  •  01-16-2007, 6:13 PM 1479 in reply to 1475

    Re: NavigateTo PreviousPage in MCML

    Hi mvarela-san, Arigato(="Thank you" in Japanese).

    Your advise gave me sight.
    If you move a page from A to B using Navigate, then you can come back to page A just clicking back button in page B.
    So I thought that MCMLPad keeps some kind of session and it should be available from mcml.

    Anyway, I tried according to your suggestion, but it didn't work.

    I located two pages.
    http://www.digicas.com/mcml/trial/FirstPage.mcml
    http://www.digicas.com/mcml/trial/NextPage.mcml

    Here's the xml to register.
    <?xml version="1.0" encoding="utf-8"?>
    <application title="WMCPL Web Application Example" id="{f2cd7fc9-a5c9-11db-96d5-005056c00008}">
      <entrypoint id="{01573692-a5ca-11db-96d5-005056c00008}"
                      addin="Microsoft.MediaCenter.Hosting.WebAddIn,Microsoft.MediaCenter"
                      title="PageSession Test"
                      description="HistoryOrientedPageSession Trial"
                      context="
    http://www.digicas.com/mcml/trial/FirstPage.mcml">
        <category category="More Programs"/>
      </entrypoint>
    </application>

    I received an exception like below:
      System.InvalidOperationException: Error evaluating path 'Session!host:History..."
      The 'Session' member on ... returned 'null' and evaluation could not continue.

    Unfortunatelly, I failed to get RC2, though SDK is the latest one.
    It might be the reason. It'll be very appreciated if you try on latest environment.

    Thank you.
    Kenichiro,

  •  01-16-2007, 11:37 PM 1488 in reply to 1479

    Re: NavigateTo PreviousPage in MCML

    Just tried it on a brand-new install of Vista Ultimate RTM - works perfectly.  Shows text at the top of the page, click it it moves to the next page, click the text on that page and it returns you to the previous page.

    My understanding is that you need to run the version of the SDK for the version of the OS you are using - so for RC1, you need the RC1 SDK.

    Do you have access to the RTM version of Vista?  Via MSDN for example?

    Cheers,
    Andrew

  •  01-16-2007, 11:54 PM 1489 in reply to 1488

    Re: NavigateTo PreviousPage in MCML

    Thank you, AndyC.
    I've spent a whole day on it yesterday. And I'd gave up this afternoon and started to seek another approach.
    I merged two pages into one (putting one UI that covers whole screen onto another, and control visibility).
    After I've finished it, I found your response...

    Anyway, It's pretty good to know that it worked. AndyC, Thank you very much. Very appreciated.

    Kenichiro,

  •  03-17-2008, 4:41 AM 7026 in reply to 1488

    Re: NavigateTo PreviousPage in MCML

    KenichiroTanaka's URL doesn't work on my Vista X64 with SP1. I got the same error message: "System.InvalidOperationException: Error evaluatin path 'Session!host:HistoryOrientedPageSession.BackPage'. The 'Session' member on 'Microsoft.MediaCenter.UI.View' returned 'null' and evaluation could not continue."

    Since PageSession is "$Required" in NextPage.mcml, you should pass a host:PageSession object to PageSession while navigating to NextPage.mcml, right? But I don't see this action in FirstPage.mcml. So, how could it work?

  •  03-17-2008, 1:27 PM 7032 in reply to 7026

    Re: NavigateTo PreviousPage in MCML

    I believe the hosting environment for web-based MCML passes this value in.

    Cheers,
    Andrew

  •  03-17-2008, 1:30 PM 7033 in reply to 7032

    Re: NavigateTo PreviousPage in MCML

    Again, just to confirm, this still works on x86 Vista Media Center (just tested).

    Cheers,
    Andrew

  •  03-18-2008, 10:53 AM 7037 in reply to 7033

    Re: NavigateTo PreviousPage in MCML

    Hmmm....strange....it doesn't work on my newly installed Vista X86 SP0 with all updates installed.
  •  03-18-2008, 11:15 AM 7038 in reply to 7037

    Re: NavigateTo PreviousPage in MCML

    How are you accessing it?

    Cheers,
    Andrew

  •  03-18-2008, 11:18 AM 7039 in reply to 7038

    Re: NavigateTo PreviousPage in MCML

    Just to check, you are running it from within Media Center not via standalone MCML Pad?  I get the exact error you describe if I run in MCML Pad.

    Cheers,
    Andrew

  •  03-18-2008, 10:11 PM 7044 in reply to 7039

    Re: NavigateTo PreviousPage in MCML

    I run it from Online Media -> program library -> MCML Preview Tool, which comes with WMC SDK 5.3.
  •  03-19-2008, 5:41 AM 7050 in reply to 7044

    Re: NavigateTo PreviousPage in MCML

    Register it using the XML file here (reposted from further up the thread):

    <?xml version="1.0" encoding="utf-8"?>
    <application title="WMCPL Web Application Example" id="{f2cd7fc9-a5c9-11db-96d5-005056c00008}">
      <entrypoint id="{01573692-a5ca-11db-96d5-005056c00008}"
                      addin="Microsoft.MediaCenter.Hosting.WebAddIn,Microsoft.MediaCenter"
                      title="PageSession Test"
                      description="HistoryOrientedPageSession Trial"
                      context="
    http://www.digicas.com/mcml/trial/FirstPage.mcml">
        <category category="More Programs"/>
      </entrypoint>
    </application>

    and it should work.  Access through it's own icon rather than McmlPad - it doesn't work in McmlPad either standalone or within Media Center.

    Cheers,
    Andrew

Page 1 of 2 (16 items)   1 2 Next >
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems