Solved

XAML Reader

Posted on 2014-02-19
10
287 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
  • 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
 
LVL 62

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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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 62

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Loop not working 29 48
Do you know how I could save the image array ELEMENTS as individual *.tiff files ? 2 40
Server Error 11 48
Run time Error 4 35
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:…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now