How to create an object reference to a xaml page from App.xaml.cs codebehind?

Posted by John K. on Stack Overflow See other posts from Stack Overflow or by John K.
Published on 2010-12-23T23:06:53Z Indexed on 2010/12/23 23:54 UTC
Read the original article Hit count: 273

Filed under:
|

Hi all,

I have a Silverlight 4 Business Project where I have enabled the ASP.NET Authentication/Authorization role information. I would like to pass the currently authenticated user's account information from the app.xaml.cs codebehind to a different XAML page, but I have no idea how that is done, or if it's even possible.

My goal is to databind the IsEnabled property of various buttons of my target XAML page, based on whether the current user is in a particular admin related role or not. The Application_UserLoaded event handler of app.xaml.cs seems to be the safest event handler to initiate this task because it fires only after the user's account information is loaded from the server.

I had previously attempted to retrieve the current user information directly from my target XAML page, but I was never getting the current user information because Application_UserLoaded hadn't finished loading the current user info yet.

public partial class App : Application
{
      private void Application_UserLoaded(LoadUserOperation operation)
      {
        // How do you create an object reference to a XAML page from your project solution
        // from this event handler?
      }
}

Thanks in advance for any assistance, John

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about xaml