As far as I can see all my custom control properties are editable directly from WPF window XAML. Is there any way to hide some of them? We have properties that have absolutely no meaning to be set when the application starts and need to be changed later at runtime.
就我所见,我所有的自定义控件属性都可以直接从WPF窗口XAML编辑。有没有办法把它们藏起来?我们有一些属性,它们在应用程序启动时完全不需要设置,需要在运行时进行更改。
The only idea that comes in my mind is to change them to methods? What do you think?
我脑子里唯一的想法就是把它们变成方法?你怎么认为?
Thanks.
谢谢。
2 个解决方案
#1
1
You can use the EditorBrowsableAttribute
to hide a property from the XAML editor. Setting this attribute to EditorBrowsableState.Never
on a property will hide it.
可以使用EditorBrowsableAttribute将属性隐藏到XAML编辑器中。将此属性设置为EditorBrowsableState。永远不要在财产上隐藏它。
[EditorBrowsable(EditorBrowsableState.Never)]
public int BusinessProperty {get; set;}
More info here: EditorBrowsableAttribute
更多信息:EditorBrowsableAttribute
#2
-1
Try something like this:
试试这样:
class Name {
public int x;
}
x will be a field, not a property.
x是一个场,不是性质。
#1
1
You can use the EditorBrowsableAttribute
to hide a property from the XAML editor. Setting this attribute to EditorBrowsableState.Never
on a property will hide it.
可以使用EditorBrowsableAttribute将属性隐藏到XAML编辑器中。将此属性设置为EditorBrowsableState。永远不要在财产上隐藏它。
[EditorBrowsable(EditorBrowsableState.Never)]
public int BusinessProperty {get; set;}
More info here: EditorBrowsableAttribute
更多信息:EditorBrowsableAttribute
#2
-1
Try something like this:
试试这样:
class Name {
public int x;
}
x will be a field, not a property.
x是一个场,不是性质。