F
F
Fr3nzy2011-08-07 20:09:45
Microsoft Silverlight
Fr3nzy, 2011-08-07 20:09:45

Silverlight, Windows Phone 7 Mango + NavigationServices.Navigate()?

The essence of the problem: when calling NavigationServices.Navigate () from a class belonging to some xaml-view, the navigation works, but when called from any auxiliary class, for some reason it doesn’t.
For example:
page MainPage.xaml, class MainPage.xaml.cs, method

NavigationServices.Navigate( new Uri("/listItems", UriKind.Relative/Absolute) )

Works.
There is also a JSON-RPC class that is used to implement communication with the server. Now, if you call Navigate () in it, then the function always returns "FileNotFound".
Function example:
public void processResponce(item Response)
{
    try
    {
        var token = Response.result.token;
        this.setToken("&token=" + token);
        Debug.WriteLine(this.apiUrl);

        (Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/listItems", UriKind.Relative));
    }
    catch
    {
        Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                var messageFromServer = Response.error.message;
                MessageBox.Show(messageFromServer);

                Debug.WriteLine(messageFromServer);
            });
    }
}

Does not work.
On the ninth line of this function, an exception is thrown about a non-existent file.
This example uses UriMapping, so the Uri is like this. I also tried to specify the full path - it does not help.
Perhaps there are some restrictions that I am not aware of?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Fr3nzy, 2011-08-07
@Fr3nzy

I'm a fool. Killed 4 hours for this. But the answer is right there! :)
If anyone encounters a similar issue, here is the answer:

  Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        (Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/listItems", UriKind.Relative));
                    });

It was just necessary to call BeginInvoke so that the application also did not swear at the lack of access rights.

Similar questions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question