Link to home
Start Free TrialLog in
Avatar of Dodsworth
Dodsworth

asked on

XAML Reader

Is there a way to programmatically access the XAML text of the currently running page in .net?
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Are you trying to do something with the XAML, or debugging?

XAML Spy
http://xamlspy.com/
Avatar of Dodsworth
Dodsworth

ASKER

I need to access it from code behind.
I don't know of a way, other than System.Windows.Markup.XamlReader.

May I ask what your use case is for reading the XAML?
Hi  Dodsworth;

When the project using XAML such as WPF and Silverlight the XAML gets compiled and becomes a BAML, Binary Application Markup Language. This is done so that the application does not get slowed down when running the code to compile it. So the simple answer is no. But XAML represents user defined controls and these controls if given a x:Name can be accessed through code.

I hope that helps.
What in particular are you trying to get at from the code-behind?
I'd like to get the complete PhoneApplicationPage XAML.
OK so I have found a means to read the XAML, but with one problem...  I can only view the compiled XAML.

My requirement is to read the current 'running' XAML, after elements have been added to the page in code behind.  Don't know how or where this is managed :(
There is no XAML for elements that are added in code-behind.
The definition of an element in XAML has the same effect as the creation of an element in code-behind and adding it as a child of some existing element: they both add the element to the Visual Tree.
Are you trying to examine the current content?
Yes
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial