Navigating to an MCML page from a dialog button

A place for App developers to hang out / post
Post Reply
brianlich

Posts: 34
Joined: Wed Jun 08, 2011 1:49 am
Location:

HTPC Specs: Show details

Navigating to an MCML page from a dialog button

#1

Post by brianlich » Tue Nov 19, 2013 4:31 am

I have a dialog box with a few buttons. When I click on a button, I'd like to navigate to a MCML page. Unfortunately, it tells me I need to be on the application thread. Is it possible to get back to it?

I'm using a callback, which I think is not run on the application thread. I'm trying to navigate back to the MCML page from within the callback when I get the error.

Here's some of the code.

The callback:

Code: Select all

        public void ScrollItemDialogCallback(Microsoft.MediaCenter.DialogResult result)
        {

            switch (result.ToString().ToUpper())
            {
                case "100":
                    this.GoToPage();
                    break;
                case "101":
                    this.Remove();
                    break;
                default:
                    break;
            }
        }
The code I'm using to try to get to the page:

Code: Select all

        public void GoToPage()
        {
            Dictionary<string, object> properties = new Dictionary<string, object>();
            properties["Application"] = this;

            if (session != null)
            {
                session.GoToPage("resx://addin/addin.Resources/Page", properties);
            }
            else
            {
                Debug.WriteLine("GoToPage");
            }
        }

sccrgoalie1

Posts: 317
Joined: Fri Jul 08, 2011 5:52 pm
Location:

HTPC Specs: Show details

#2

Post by sccrgoalie1 » Tue Nov 19, 2013 2:09 pm

brianlich wrote:I have a dialog box with a few buttons. When I click on a button, I'd like to navigate to a MCML page. Unfortunately, it tells me I need to be on the application thread. Is it possible to get back to it?

I'm using a callback, which I think is not run on the application thread. I'm trying to navigate back to the MCML page from within the callback when I get the error.

Here's some of the code.

The callback:

Code: Select all

        public void ScrollItemDialogCallback(Microsoft.MediaCenter.DialogResult result)
        {

            switch (result.ToString().ToUpper())
            {
                case "100":
                    this.GoToPage();
                    break;
                case "101":
                    this.Remove();
                    break;
                default:
                    break;
            }
        }
The code I'm using to try to get to the page:

Code: Select all

        public void GoToPage()
        {
            Dictionary<string, object> properties = new Dictionary<string, object>();
            properties["Application"] = this;

            if (session != null)
            {
                session.GoToPage("resx://addin/addin.Resources/Page", properties);
            }
            else
            {
                Debug.WriteLine("GoToPage");
            }
        }
Take a look at Application.DeferredInvoke and Application.DeferredInvokeonWorkerThread

sccrgoalie1

Posts: 317
Joined: Fri Jul 08, 2011 5:52 pm
Location:

HTPC Specs: Show details

#3

Post by sccrgoalie1 » Tue Nov 19, 2013 4:27 pm

And here's an example

Code: Select all

public void NavigateSearchByTitleAndDescription()
{           
     isBusy = true;
     Microsoft.MediaCenter.UI.Application.DeferredInvokeOnWorkerThread(new DeferredHandler(rpMediaCenter.Potatoes[0].ConnectForSearch), new DeferredHandler(NavigateSearchByTitleAndDescriptionDeferred), new object[1]);
}

public void NavigateSearchByTitleAndDescriptionDeferred(object oargs)
        {
            Dictionary<string, object> properties = new Dictionary<string, object>();
            properties["SearchListings"] = mSearchListings;
            isBusy = false;
            session.GoToPage("resx://SharedGuidePotato/SharedGuidePotato.Resources/SearchListings", properties);

        }
          

brianlich

Posts: 34
Joined: Wed Jun 08, 2011 1:49 am
Location:

HTPC Specs: Show details

#4

Post by brianlich » Tue Nov 19, 2013 5:36 pm

Thanks!

Post Reply