XAML Reader

Is there a way to programmatically access the XAML text of the currently running page in .net?
LVL 1
DodsworthAsked:
Who is Participating?
 
Fernando SotoRetiredCommented:
Maybe this will help you. VisualTreeHelper Class, At the bottom of the page you will find a code snippet on how to visit all the nodes in the tree.
0
 
Bob LearnedCommented:
Are you trying to do something with the XAML, or debugging?

XAML Spy
http://xamlspy.com/
0
 
DodsworthAuthor Commented:
I need to access it from code behind.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Bob LearnedCommented:
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?
0
 
Fernando SotoRetiredCommented:
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.
0
 
MikeTooleCommented:
What in particular are you trying to get at from the code-behind?
0
 
DodsworthAuthor Commented:
I'd like to get the complete PhoneApplicationPage XAML.
0
 
DodsworthAuthor Commented:
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 :(
0
 
MikeTooleCommented:
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?
0
 
DodsworthAuthor Commented:
Yes
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.