Solved

XAML Reader

Posted on 2014-02-19
10
286 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 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

19 Experts available now in Live!

Get 1:1 Help Now