gpt4 book ai didi

c# - 以编程方式将 LayoutAnchorable 添加到 DockManager

转载 作者:太空宇宙 更新时间:2023-11-03 15:55:49 24 4
gpt4 key购买 nike

我正在尝试以编程方式将新的 LayoutAnchorable 添加到我的 AvalonDock DockingManager 实例。

使用下面的代码,anchorable 出现了,但它是空白的(内容不显示),并且按钮不起作用( float 、自动隐藏、关闭等)。

控件确实在将它(在运行时)拖入和拖出我的 LayoutDocumentPane 后开始按预期工作,尽管关闭按钮没有出现(这是一个单独的问题)。

var anchorable = new LayoutAnchorable
{
Content = control,
Title = "Configuration",
ContentId = "ConfigurationId",
IsActive = true,
IsSelected = true,
CanFloat = true,
CanAutoHide = false,
CanClose = true,
CanHide = false,
};

anchorable.AddToLayout( DockingManager, AnchorableShowStrategy.Left );

我已经尝试浏览 AvalonDock 源代码,但我找不到任何明显的东西。

我希望以编程方式添加它,而不是使用 MVVM。

最佳答案

如果您希望始终将添加添加到您正在添加的文档的同一 Pane 中,您可以这样做。HomePage.homepage 是包含停靠管理器的窗口的静态成员。doc 是对当前文档的引用。

LayoutDocument ld = new LayoutDocument();
ld.Content = new NewDonor(ld);
LayoutDocumentPane pane = ((doc.FindParent<LayoutDocumentPane>() ?? (HomePage.homepage.panal.Children?[0] as LayoutDocumentPane)) ?? new LayoutDocumentPane());
pane.Children.Add(ld);
if (HomePage.homepage.panal.ChildrenCount == 0)
{
HomePage.homepage.panal.Children.Add(pane);
}
ld.IsSelected = true;

关于c# - 以编程方式将 LayoutAnchorable 添加到 DockManager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23681078/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com