[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 297
  • Last Modified:

XAML Reader

Is there a way to programmatically access the XAML text of the currently running page in .net?
0
Dodsworth
Asked:
Dodsworth
  • 4
  • 2
  • 2
  • +1
1 Solution
 
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
 
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

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

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now