User Profile & Activity

Alastair Taylor Member
Posted: May 27, 2011 2:33 AM

Works like a dream Riendy - many thanks for this and the quick turnaround. 

All the best,

Alastair

Posted: May 21, 2011 8:00 AM

Thanks Riendy, have emailed you the address.

Appreciate the efforts here folks, thanks.

Posted: May 17, 2011 11:04 PM

Hi Jimmy.

Still failing with no ExtraData. I grabbed the nightly from 13th May, sample with DLLs attached. Maybe I'm doing something odd?

All the best,

Alastair

Posted: May 17, 2011 11:01 PM

[moved post below]

Posted: May 11, 2011 4:18 AM

Hi Jimmy,

I've attached a full sample. It's the vanilla Navigation app with authentication added. I picked apart the Silverlight samples and an earlier custom authentication sample on the boards. The examples are great by the way...

The authentication manager accepts "user" and "password" as a good credential. This is just for the example, obviously the backend authentication will be slightly stronger..;)

The settings page is set to require authentication: RequiresAuthentication="True"

When we navigate to Settings first time around, the LoginForm is invoked to get the credential. If this is successful, we return to the Home page, as the ExtraData doesn't contain the URI of the Settings page that invoked the form.

   public partial class LoginForm : UXPage
    {
        public LoginForm()
        {
            InitializeComponent();
        }
        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // Get a reference to the NavigationService that navigated to this Page
            // If the login page was redirected from a protected page,
            // the e.ExtraData will include the URI of the original caller page.
            if (e.ExtraData != null && e.ExtraData is NavigationOptions)
            {
                // bind the URI to our view model, so we can redirect back 
                // to the original page when the login succeeded.
                LoginFormViewModel viewModel = this.DataContext as LoginFormViewModel;
                viewModel.OriginalUri = ((NavigationOptions)e.ExtraData).NavigateUri;
            }
        }
    }

 

We can then navigate manually to the Settings page, and it displays if the authentication was ok. 

I was hoping to drop into the Settings page directly once the authentication is good:

            if (loginOperation.LoginSuccess)
            {
                // Login success, navigate to the page that originally requesting access
                
                // need to make ui calls on same thread as ui (sta threading model)
                // callback is created as a different thread
                // http://stackoverflow.com/questions/351676/problem-using-multithreading-with-simple-wpf-app 
                System.Windows.Application.Current.Dispatcher.Invoke(new System.Action(() => { NavigationServiceProvider.Navigate(this.OriginalUri); }));
            }

It's the OriginalUri not being set to SettingsPage because of no ExtraData. So we default to Home.

I'm pretty new to WPF - and as I said - ClientUI is an excellent product and making my life a lot easier. But I may have missed something obvious. Is there there a way to override the framework and provide the extra data myself?

All the best,

Alastair

Thanks for the quick response Riendy.

I didn't explicitly call the navigate function to pass the extradata,  simply implemented OnNavigatedTo in the navigatedto page.

Is there a way to catch the 'about to navigate' on the source page, and add the extradata myself? That would work for me.

All the best,

Alastair


All times are GMT -5. The time now is 5:51 PM.
Previous Next