Solved

XAML Reader

Posted on 2014-02-19
10
290 Views
Last Modified: 2014-02-24
Is there a way to programmatically access the XAML text of the currently running page in .net?
0
Comment
Question by:Dodsworth
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
10 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 39873331
Are you trying to do something with the XAML, or debugging?

XAML Spy
http://xamlspy.com/
0
 
LVL 1

Author Comment

by:Dodsworth
ID: 39873554
I need to access it from code behind.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 39873842
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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 63

Expert Comment

by:Fernando Soto
ID: 39873898
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
 
LVL 27

Expert Comment

by:MikeToole
ID: 39874695
What in particular are you trying to get at from the code-behind?
0
 
LVL 1

Author Comment

by:Dodsworth
ID: 39876172
I'd like to get the complete PhoneApplicationPage XAML.
0
 
LVL 1

Author Comment

by:Dodsworth
ID: 39876219
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
 
LVL 27

Expert Comment

by:MikeToole
ID: 39876891
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
 
LVL 1

Author Comment

by:Dodsworth
ID: 39876912
Yes
0
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 39876948
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

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
locate sql commands in C# visual studio Project 6 44
ASP.NET Built-In Report Creator / Viewer 5 25
Need help with another query 10 39
Web page design problem 3 18
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question