如何创建包含多个属性的属性 [英] how to make a property containing several properties

查看:78
本文介绍了如何创建包含多个属性的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
如何制作包含多个属性的属性

像这样:

http://i.stack.imgur.com/5HtfE.jpg [ ^ ]



我想在一个属性的名称下集成一个组的属性属性窗口

谢谢

解决方案

看看这里: 如何使用嵌套属性创建用户控件 [< a href =http://www.codeproject.com/Answers/1005890/How-to-create-user-control-with-nested-properties?arn=0target =_ blanktitle =New Window> ^ ]

我在解决方案中更快地讨论了(3)


请参阅我对该问题的评论。它没有多大意义。如果您不了解房产是什么,您应该问其他一些问题。如果你理解它,你应该明白属性类型可以是任何东西,例如, struct ,任何成员,也可以是属性。



-SA


这是一个WPF(或Windows窗体)中控件的属性。您应该知道的一件事是Visual Studio本身就为您提供了这个功能,因此您无需在编程的深度中进行解决。实际上,看起来像这样



 control.Padding =  new 厚度(
0 // Left
0 // 顶部
0 // 正确
0 // 底部
);





Visual Studio简单地从您的代码中抽象出来。由于解决方案1 ​​告诉您属性可以是任何可用于更改对象状态或将两个对象彼此区分开的属性。例如,可以通过它们具有的填充来区分两个控件。



这种抽象是你认为持有其他财产的财产。但这只是一个属性窗口,允许您在其中输入值,并让Visual Studio为您生成后端的代码文件。您可以使用任何类型创建(类的)属性。



  class  Obj {
public 类型属性{ get ; set ; }
}





在上面的代码中,你可以设置任何类型( string int DateTime Window 或任何可以作为类型使用的东西,而属性将是名称。在Visual Studio中,您可以创建一个扩展,管理如何向用户显示属性。 C#并不关心它。也就是说,要获得值列表,可以使用List(泛型集合)并在其中保存值列表。例如,



  public  人{
public 列表< string>兴趣{获取; set ; } // 兴趣列表。
}


hi how can i make a property containing several properties
like this:
http://i.stack.imgur.com/5HtfE.jpg[^]

I want to integrate the propertis of a group under the name of one property in the properties window
thank you

解决方案

Take a look to here : How to create user control with nested properties[^]
I discussed the same sooner in the Solution (3)


Please see my comment to the question. It doesn't really make sense. If you don't understand what a property is, you should have asked some other question. If you do understand it, you should understand that the property type can be anything, for example, a class or struct, with any members, which can also be properties.

—SA


That is a property of a control in WPF (or maybe Windows Forms). One thing you should know is that Visual Studio is providing you with this feature itself, so that you do not have to work around in the depth of programming. In real, that looks something like this

control.Padding = new Thickness (
                      0, // Left
                      0, // Top
                      0, // Right
                      0  // Bottom
                  );



Visual Studio simply abstracts the code from you. As Solution 1 tells you that a property can be anything that can be used to change the state of an object or to distinguish two objects from each other. For example, two controls can be distinguished by the padding they have.

That abstraction is what you think as a property holding other properties. But that is just a Properties Window allowing you to enter values in it and letting Visual Studio generate a code file on the back end for you. You can create a property (of a class) with any type.

class Obj {
   public Type Property { get; set; }
}



In the above code, you can set anything to Type (string, int, DateTime, Window or anything that can be used as a type) and the Property would be the name. In Visual Studio, you can then create an extension that manages how the property is shown to the user. C# doesn't care about it. That said, to have a list of values, you can use a List (generic collection) and hold a list of values in that. For example,

public class Person {
   public List<string> Interests { get; set; } // List of interests.
}


这篇关于如何创建包含多个属性的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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