在UserControl中创建嵌套属性,或在Parent属性中创建多个子属性 [英] Create a nested property in UserControl Or Multiple child properties in Parent Property
问题描述
示例:样式标签:哪些属性具有字体,颜色,显示等属性?接受对象及其值.
任何人都可以添加有关如何创建具有多个子属性或简短嵌套属性的父属性的完整输入.
例如:
Example: Style tag: which has properties like font, color, display… etc? which accept objects and its value.
Can anyone add a complete input about how to create Parent Property with multiple child properties or in short nested properties.
Eg:
<Uc:Control Id="UControl1"" Rainbow="Red:true;Blue=false;Green:true;" />;
键入Rainbow属性后,它将立即获得颜色数量的列表.他可以选择这些颜色的列表并为其指定值.
As soon as Rainbow property is typed, it will get a list of number of colors. He can select list of those colors and assign a value to them.
推荐答案
属性类似于属性.....
属性可以是引用类型或值类型...
引用类型=任何类,例如"String","DateTime","SqlConnection" ..
我们使用"new"关键字进行初始化的方式....
和
值类型=任何类型,例如..."string","int","float","double" ........
现在,如果您想要父级属性和子级属性...
使用这个....
首先制作引用类型......
Property is something like attribute.....
a property can be reference type or value type...
reference type = any class like "String","DateTime","SqlConnection"..
what we use "new" keyword to initialize....
and
value type = any type like..."string","int","float","double"........
now if you want a Parent Property and Child Properties......
Use this....
first making the reference type ......
public class RainbowClass
{
bool red,blue,green;
public RainbowClass()
{
red=false;
blue=false;
green=false;
}
public bool Red
{
get
{
return red;
}
set
{
red=value;
}
}
public bool Blue
{
get
{
return blue;
}
set
{
blue=value;
}
}
public bool Green
{
get
{
return green;
}
set
{
green=value;
}
}
}// end of you sub class type....
现在在您的用户控件中....创建这样的属性...
now in your user control....make a property like this...
RainbowClass rainbowObject;//global variable of your user control
public RainbowClass Rainbow
{
get
{
return rainbowObject;
}
set
{
rainbowObject=value;
}
}
可能是我误解了您的问题,并且可能发布了不相关的答案....请不要介意这样子
may be i misunderstood your question and i may have posted irrelevant answer.... plz dont mind if it is like that
这篇关于在UserControl中创建嵌套属性,或在Parent属性中创建多个子属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!