创建项模板并隐藏自定义方法将其添加到项目中 [英] Create Item Template and Hide Custom Method When add it to the project

查看:79
本文介绍了创建项模板并隐藏自定义方法将其添加到项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好


我有疑问。我创建了一个自定义用户控件。我的CustomUserControl继承自UserControl。我在CustomUserControl中添加了一些自定义方法和属性。我想将我的  CustomUserControl添加到"添加新项目"中在Visual Studio
中用于项目。


为此,我使用了"项目模板"。并创建了一个模板。重新启动Visual Studio后,每件事都很好,我可以使用"添加新项"添加我的CustomUserControl。在我的项目中。


当我将CustomUserControl添加到我的项目时,我遇到了问题,我添加到模板文件中的方法和属性出现了,我可以更改它们。如何在模板中隐藏方法和属性?我不希望在
之后看到方法和属性将CustomUserControl添加到项目中。


谢谢


祝你好运,

解决方案

你好TyfnCtn,


欢迎来到MSDN论坛。


你是如何创建的客户用户控制?对于项目模板,预计会看到所有这些方法和属性
,它似乎也无法隐藏它们。


也许您可以尝试使用控件创建自定义用户控件库,然后将其添加到项目的工具箱中,
使用它,请查看以下内容:


  1. < span style ="font-size:11.0pt; font-family:'Calibri',sans-serif; color:black">创建一个像WPF控件库一样的C#控件库
  2. 拖动一些控件并自定义
  3. 构建此解决方案和操作在bin \debug文件夹中查找.dll文件
  4. 创建一个新的WPF项目并打开工具箱,然后将上面的.dll文件拖到工具箱中,然后这个自定义控件将显示在工具箱中,我们现在就可以使用它了


希望以上所有内容都有助于解决您的问题。期待您的回复!



最好的问候,


萨拉


Hello

I have question. I created a custom user control. My CustomUserControl is inherited from UserControl. I add some custom methods and properties in my CustomUserControl. I wanted to add my CustomUserControl to "Add New Item" in Visual Studio for projects.

For this I used "Item Template" and created a template. After restarting Visual Studio every thing was fine and I could add my CustomUserControl by using "Add New Item" in my project.

Just i have a problem when I add CustomUserControl to my project, the methods and properties that I am added into template file appeare and i can change them. How can I Hide methods and property in template? I don't want to see methods and properties after add CustomUserControl to project.

Thank you

Best regards,

解决方案

Hi TyfnCtn,

Welcome to the MSDN forum.

How did you create the customer user control? For the item template, it is expected to see all those methods and properties and it also seems cannot hide them.

Maybe you can try to create a custom user control using the control library, then add it to the toolbox of your project and use it, please have a look at the following:

  1. Create a C# control library like WPF Control Library
  2. Drag some controls and custom them
  3. Build this solution and open the bin\debug folder to find the .dll file
  4. Create a new WPF project and open the Toolbox, then drag the above .dll file into the toolbox, then this custom control will display in the toolbox and we can use it now

Hoping all above can help solve your problem. Looking forward to hearing from you!

Best regards,

Sara


这篇关于创建项模板并隐藏自定义方法将其添加到项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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