Mailbag: How can I create a loading page for an MCML application?
I am building a Windows Media Center application for Windows Vista using Media Center Markup Language (MCML). My application performs some initialization tasks that are somewhat time intensive, so I would like to display a page with a loading animation so the user will know that something is happening behind the scenes. Once the application initialization is complete, I would like to navigate to the main page for my application.
Is it possible to architect my MCML application so that it has a loading page to give the user a sense of progress, then navigates to a new page when loading is complete? Also, is it possible to prevent Media Center from showing the loading page if the user presses back from the main application page?
The HistoryOrientedPageSession class is derived from the PageSession class. The PageSession class contains a LoadPage method that can be used to display a page that will not be added to the Media Center back stack. The LoadPage method is protected, so you cannot instantiate a HistoryOrientedPageSession object and call LoadPage directly.
However, you can create a sub-class of HistoryOrientedPageSession and then call LoadPage from your sub-class. This will allow your application to navigate to a page that will not appear on the back stack and then transition to another page that will appear on the back stack.
In addition, you can create a property in your application code and fire a property change event when your application initialization is complete. Then you can add a Rule to your MCML page that listens for this property change event and navigates to the main page of your application.
The Q podcast application included as a sample in the Windows Media Center SDK for Windows Vista demonstrates how to implement all of the above logic. It contains a loading page that does not re-appear when the user presses back within Media Center, and it fires a property change event and uses a rule to navigate to the main application page after loading is complete.
If you have the Media Center SDK installed to the default path, you can take a look at the following files to look at the exact implementation details:
•QAddIn.cs (located at C:\Program Files\Microsoft SDKs\Windows Media Center\v5.0\Samples\Windows Media Center Presentation Layer Samples\Q) - this file contains a class named QAddInPageSession that sub-classes HistoryOrientedPageSession and implements the LoadPage method to load the MCML file named Loading.mcml that is embedded into the Q application DLL as a managed resource
•FeedLoader.cs (located at C:\Program Files\Microsoft SDKs\Windows Media Center\v5.0\Samples\Windows Media Center Presentation Layer Samples\Q\Code\RssFeedHandling) - this file fires an IsComplete property change that the MCML markup in the application has a rule to react to in order to navigate to the main page of the application (Q.mcml)
•Loading.mcml (located at C:\Program Files\Microsoft SDKs\Windows Media Center\v5.0\Samples\Windows Media Center Presentation Layer Samples\Q\Markup) - this file contains the MCML markup to display a loading page and wait for the IsComplete property change to be fired by the application. Once the property change is fired, the loading page uses a Navigate element to navigate to the main page of the application
It is important to note that the algorithm described above only works for locally installed MCML applications. Windows Media Center web applications do not have any locally installed code, so it is not possible to sub-class HistoryOrientedPageSession and fire property changes as described above.
It is possible to dynamically change the Source property on a Host view item in your markup file (similar to what is demonstrated in the AdvancedMarkup.HostViewItem.mcml sample in McmlSampler in the SDK) to create a loading page in an MCML web application that will navigate to the main page of the application. However, doing this will cause the loading page to be placed on the back stack. This means that the loading page will re-appear when pressing back after your application navigates to the main page.
A place for App developers to hang out / post
1 post • Page 1 of 1