提取正在运行的 WPF 应用程序的 WPF 内容模板

发布于 2024-09-25 00:18:52 字数 186 浏览 5 评论 0原文

有没有办法提取托管在正在运行的 WPF 应用程序中的 WPF 控件的内容模板?

就像我能够使用 Snoop 等工具挖掘任何 WPF 应用程序的可视化树一样,我希望能够提取内容模板。

我已经问过谷歌了。但要么我的关键字完全错误,要么可能没有解决方案(我对此表示怀疑)。

有人可以给我提示吗?

谢谢

is there a way of extracting a content template of a WPF control which is hosted in a running WPF application?

Just the same way as I am able to dig through the visual tree of any WPF application with tools like Snoop I'd like to be able to extract the Content Template.

I have asked Google already. But either my keywords were totally wrong or there might be no solution (what I doubt).

Could please someone give me a hint?

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我喜欢麦丽素 2024-10-02 00:18:52

您对这个小扩展方法有何看法?

using XamlWriter = System.Windows.Markup.XamlWriter;
public static class FrameworkTemplateExtensions
{
    /// <summary>
    /// Returns properly-indented XAML representing the given template.
    /// </summary>
    public static string AsXaml(this FrameworkTemplate template)
    {
        if (template == null)
        {
            return null;
        }
        XmlWriterSettings xmlSettings = new XmlWriterSettings();
        xmlSettings.Indent = true;
        StringBuilder builder = new StringBuilder();
        using (XmlWriter writer = XmlWriter.Create(builder, xmlSettings))
        {
            XamlWriter.Save(template, writer);
        }
        return builder.ToString();
    }
}

What do yo think about that small extension method?

using XamlWriter = System.Windows.Markup.XamlWriter;
public static class FrameworkTemplateExtensions
{
    /// <summary>
    /// Returns properly-indented XAML representing the given template.
    /// </summary>
    public static string AsXaml(this FrameworkTemplate template)
    {
        if (template == null)
        {
            return null;
        }
        XmlWriterSettings xmlSettings = new XmlWriterSettings();
        xmlSettings.Indent = true;
        StringBuilder builder = new StringBuilder();
        using (XmlWriter writer = XmlWriter.Create(builder, xmlSettings))
        {
            XamlWriter.Save(template, writer);
        }
        return builder.ToString();
    }
}
你怎么敢 2024-10-02 00:18:52

模板在 Xaml 中定义,最终成为二进制 Xaml (Baml),这将使反编译 Xaml 格式的模板变得更加困难(如果不是不可能的话)。

The Template is defined in Xaml, which ends up as Binary Xaml (Baml), which is going to make it much harder, if not impossible, to get the Template in Xaml format decompiled.

旧时模样 2024-10-02 00:18:52

该工具允许您查看正在运行的 WPF 树。只要您没有同时使用 VS 调试应用程序即可。

http://snoopwpf.codeplex.com/

This tool allows you to view the running WPF tree. So long as you aren't debugging the application with VS at the same time.

http://snoopwpf.codeplex.com/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文