C# 如何将 Metro UI 控件添加到 Visual Studio 的工具箱中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18538550/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 12:30:40  来源:igfitidea点击:

How do I add the Metro UI controls to the toolbox in visual studio?

c#visual-studio-2013

提问by Victorio Berra

Metro controls: https://github.com/viperneo/winforms-modernui

地铁控制:https: //github.com/viperneo/winforms-modernui

I am trying to use the metro controls and I am going off of what I can from the sample project. What I cant seem to figure out is how to add the controls to my toolbox for easy drag and drop.

我正在尝试使用地铁控件,但我正在从示例项目中获得我所能做的。我似乎无法弄清楚如何将控件添加到我的工具箱中以便于拖放。

I right click my toolbox, select "choose toolbox items" and then I browse for the MetroFramework.dll and it adds all the controls, however when I try to use a control I get "Failed to create MetroLabel" a reference to the component "MetroFramework" already exists in the project. I do in fact have MetroFramework.Design and MetroFramework.Fonts added to my solution and referenced in my project.

我右键单击我的工具箱,选择“选择工具箱项目”,然后浏览 MetroFramework.dll 并添加所有控件,但是当我尝试使用控件时,我收到“无法创建 MetroLabel”对组件的引用“ MetroFramework”已存在于项目中。事实上,我确实将 MetroFramework.Design 和 MetroFramework.Fonts 添加到我的解决方案中并在我的项目中引用。

采纳答案by cdturner

  1. use nuget to add the modernui to your project.
  2. all forms inherit from MetroFramework.Forms.MetroForm
  3. setup your toolbox panels with the "choose", you have to use browse to navigate and find the metroframework .net dll in the packages folder. pick the one for your build, so .net4 for .net 4 ..etc
  4. that gets you a toolbox panel with "Metrobutton" ..etc.
  5. from that panel drag drop a MetroStyleManager control onto your form. It will keep all the styling on your page the same. then you can set the style and theme once in the constructor. I suggest you make those objects public, then its easy to pass style and theme to any sub windows with ease.
  1. 使用 nuget 将 Modernui 添加到您的项目中。
  2. 所有表单都继承自 MetroFramework.Forms.MetroForm
  3. 使用“选择”设置您的工具箱面板,您必须使用浏览来导航并在包文件夹中找到metroframework .net dll。为您的构建选择一个,因此 .net4 为 .net 4 ..etc
  4. 这为您提供了一个带有“Metrobutton”的工具箱面板..等。
  5. 从该面板将 MetroStyleManager 控件拖放到您的表单上。它将使您页面上的所有样式保持不变。然后您可以在构造函数中设置一次样式和主题。我建议您将这些对象设为公开,然后轻松地将样式和主题传递给任何子窗口。

there is a limited set of controls, but should get you started. (I've just played with it for a few hours)

有一组有限的控件,但应该可以帮助您入门。(我刚玩了几个小时)