获取指定Silverlight控件的Xaml [英] Get the Xaml for the specified Silverlight Control

查看:54
本文介绍了获取指定Silverlight控件的Xaml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了RichTextBox之外,我还没有找到一种方法来在Silverlight4中检索Control的XAML.有办法吗?

我想出(但尚未经过测试)的解决方法是创建一个XamlElement类,该类允许您指定属性,内容和子元素.一旦用代码构建了控件(并且构建了我的XamlElement集合),我就可以调用GetXaml()方法,该方法返回该元素的所有xaml(包括子属性和/或内容). />
有任何想法吗?

Other than the RichTextBox, I haven''t found a way to retrieve the XAML for a Control in Silverlight4. Is there a way?

A work-around I''ve come up with (but haven''t yet tested) is to create a XamlElement class that allows you to specify attributes, content, and child elements. Once the control has been constructed in code (and my XamlElement collection has been built), I can call a GetXaml() method that returns all of the xaml for the element (including children attributes, and/or content).

Any ideas? Suggestions?

推荐答案

我不知道这是否适用于SilverLight,但如果您没有其他任何答案,那可能值得您注意.

您可以从下载Charles Petzold的书"Applications = Code + Markup"随附的源代码.此处 [ ^ ].在第25章的代码中有一个"DumpControlTemplate"项目.
I don''t know if this works for SilverLight but if you don''t get any other answers it might be worth your looking.

You can download the sourcecode that accompanies Charles Petzold''s book "Applications = Code + Markup" from here[^]. In the code for Chapter 25 there is a ''DumpControlTemplate'' project.


这篇关于获取指定Silverlight控件的Xaml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆