0

我想在我的 WPF 项目中实现这个控件,但我不知道这个控件的名称是什么? 在此处输入图像描述 以前有人做过这个吗?请给我有关此控件的信息。谢谢

4

3 回答 3

0

第一级查询将确定控件是否实际上是 WPF 控件。为此,您可以使用 WPF Snoop Utility。如果该实用程序检测到 WPF 控件,它将产生一个像这样的屏幕......

窥探显示

如此图所示,您将能够检查可视化树并确认它实际上是一个 WPF 控件。之后,就可以找到作者使用的 Xaml 并将其重新部署到您的应用程序中。如果您无法获得 Xaml,则必须使用 Snoop(或其他类似实用程序)对控件进行“逆向工程”。

Snoop 在这里... https://snoopwpf.codeplex.com/

如果您无法获得 Xaml,或者它不是 WPF 控件,那么您需要从头开始进行“逆向工程”。HighCore 表示这是一项微不足道的任务,我同意他的看法。

如果真的可以获取到控件的实例,可以使用这个方法来获取模板...

    public void DefaultControlTemplateLoaded(TreeView sender, RoutedEventArgs e)
    {
        StringBuilder stringBuilder = new StringBuilder();
        XmlWriterSettings xmlSettings = new XmlWriterSettings();
        xmlSettings.Indent = true;
        using (XmlWriter xmlWriter = XmlWriter.Create(stringBuilder, xmlSettings))
        {
            XamlWriter.Save(sender.ItemsPanel, xmlWriter);
        }
        Console.WriteLine(stringBuilder.ToString());
    }

为此,您必须加载程序集并四处寻找,直到找到声明并使用激活器创建实例。

确保产品具有允许“逆向工程”的许可证!

于 2013-07-04T15:37:09.973 回答
0

你是说工具栏?它不存在,你必须自己实现它,为你想要的每种视图创建不同的数据模板,然后在它们之间切换

于 2013-07-04T14:44:15.930 回答
0

If you want to create these kind of views you can create custom views for listview check out here

Although if you want ot know the name of the control. then use the Snoop to genrate the WPF visual tree for you and then you can see the names of the control is being rendered. on the controls.

Or the other way use the VisualTreeHelper.GetChild methods

// Enumerate all the descendants of the visual object. 
static public void EnumVisual(Visual myVisual)
{
    for (int i = 0; i < VisualTreeHelper.GetChildrenCount(myVisual); i++)
    {
        // Retrieve child visual at specified index value.
        Visual childVisual = (Visual)VisualTreeHelper.GetChild(myVisual, i);

        // Do processing of the child visual object. 

        // Enumerate children of the child visual object.
        EnumVisual(childVisual);
    }
}
于 2013-07-04T15:33:06.217 回答