tags:

views:

16

answers:

1

Hi,

To navigate to a specific page in the assembly, the typical code looks like:

NavigationService.Navigate(new Uri("pagename.xaml", UriKind.Relative));

I was wondering if there is a way to read the contents of this XAML file or may be a way to decompile the embedded BAML file from the assembly directly.

+2  A: 

To instantiate the control from your assembly you need to do the following:

    Uri uri = new Uri( "/YourApplication;component/YourWindow.xaml", 
                    UriKind.Relative );
    Window window = (Window)Application.LoadComponent(uri);

where Window is the top element of this file. If you want the actual XAML you can use XamlWriter to give that to you:

String xaml = XamlWriter.Save( window );
Ivan Zlatanov
Thanx a lot this works.
Shailesh Kumar