?
Solved

XAML Reader

Posted on 2014-02-19
10
Medium Priority
?
292 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
Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

 
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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses

743 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