[英]AvalonDock: Dynamically changing LayoutAnchorablePane's CanClose property
In AvalonDock, is it possible to modify a LayoutAnchorablePane
's CanClose
property dynamically at runtime?在 AvalonDock 中,是否可以在运行时动态修改
LayoutAnchorablePane
的CanClose
属性? I would like to prevent/lock layout changes unless the user specifically desires to do so and turns it on.我想阻止/锁定布局更改,除非用户特别希望这样做并打开它。
I have tried the following approaches:我尝试了以下方法:
DependencyProperty
so something like this doesn't work: <dock:LayoutAnchorable CanClose="{Binding CanClose}">
DependencyProperty
,所以这样的东西不起作用: <dock:LayoutAnchorable CanClose="{Binding CanClose}">
CanClose
property: Changing the LayoutAnchorablePane
's CanClose
property in code-behind is not possible because the property is read-only. CanClose
属性:无法在代码隐藏中更改LayoutAnchorablePane
的CanClose
属性,因为该属性是只读的。According to the source code of LayoutAnchorablePane
:根据
LayoutAnchorablePane
的源代码:
#region CanClose
public bool CanClose
{
get
{
return Children.All( a => a.CanClose );
}
}
#endregion
the CanClose
property depends on all children of the pane, so one way to change the value of CanClose
of a LayoutAnchorablePane
is to set all its children's CanClose
property to the value you want. CanClose
属性取决于窗格的所有子级,因此更改CanClose
的LayoutAnchorablePane
值的一种方法是将其所有子级的CanClose
属性设置为所需的值。 Below is an example:下面是一个例子:
...
foreach(var child in pane.Children)
{
child.CanClose = true; // or false.
}
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.