Prism、AvalonDock 区域适配器(处理关闭 DocumentPane 事件)
我有一个 Prism v4 / MEF / WPF 解决方案,可将模块视图加载到我的 Avalon Dock 中的 DocumentPane 中。我正在尝试创建关闭事件的句柄(当按下“X”来关闭 DocumentPane 时)。我无法弄清楚,这是我的 RegionAdapter 类中创建 DockableContent 的部分,也是我尝试处理关闭事件的部分(我尝试了 3 个事件):
private void OnViewsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e, IRegion region, DocumentPane regionTarget)
{
if (e.Action == NotifyCollectionChangedAction.Add)
{
foreach (object item in e.NewItems)
{
UIElement view = item as UIElement;
if (view != null)
{
DockableContent newContentPane = new DockableContent()
{
Content = item,
Title = ((ITabViewInfo)view).TabViewTitle
Icon = ((ITabViewInfo)view).TabViewIcon
};
newContentPane.Closed += new EventHandler(newContentPane_Closed);
newContentPane.Manager.DocumentClosed +=new EventHandler(Manager_DocumentClosed);
newContentPane.Manager.DocumentClosing +=new EventHandler<System.ComponentModel.CancelEventArgs>(Manager_DocumentClosing);
regionTarget.Items.Add(newContentPane);
newContentPane.Activate();
}
}
}
else if (e.Action == NotifyCollectionChangedAction.Remove)
{
// this is never hit
Debug.WriteLine("removed");
}
}
这些事件永远不会被命中(我有一个 debug.writeline在每一个中):
newContentPane.Closed += new EventHandler(newContentPane_Closed);
newContentPane.Manager.DocumentClosed +=new EventHandler(Manager_DocumentClosed);
newContentPane.Manager.DocumentClosing +=new EventHandler<System.ComponentModel.CancelEventArgs>(Manager_DocumentClosing);
如何处理 DocumentPane 的关闭事件?
我用于此 RegionAdapter 的代码基于 http://blog.raffaeu.com/archive/2010/07/04/wpf-and-prism-tab-region-adapter-part-02.aspx
I have a Prism v4 / MEF / WPF solution that loads module views into a DocumentPane in my Avalon Dock. I'm trying to create a handle on the close event (when the 'X' is pressed to close a DocumentPane). I can't figure it out, this is the portion of my RegionAdapter class that creates the DockableContent and also where I attempt to handle the close event (I tried with 3 events):
private void OnViewsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e, IRegion region, DocumentPane regionTarget)
{
if (e.Action == NotifyCollectionChangedAction.Add)
{
foreach (object item in e.NewItems)
{
UIElement view = item as UIElement;
if (view != null)
{
DockableContent newContentPane = new DockableContent()
{
Content = item,
Title = ((ITabViewInfo)view).TabViewTitle
Icon = ((ITabViewInfo)view).TabViewIcon
};
newContentPane.Closed += new EventHandler(newContentPane_Closed);
newContentPane.Manager.DocumentClosed +=new EventHandler(Manager_DocumentClosed);
newContentPane.Manager.DocumentClosing +=new EventHandler<System.ComponentModel.CancelEventArgs>(Manager_DocumentClosing);
regionTarget.Items.Add(newContentPane);
newContentPane.Activate();
}
}
}
else if (e.Action == NotifyCollectionChangedAction.Remove)
{
// this is never hit
Debug.WriteLine("removed");
}
}
These events are never hit (I have a debug.writeline in each one):
newContentPane.Closed += new EventHandler(newContentPane_Closed);
newContentPane.Manager.DocumentClosed +=new EventHandler(Manager_DocumentClosed);
newContentPane.Manager.DocumentClosing +=new EventHandler<System.ComponentModel.CancelEventArgs>(Manager_DocumentClosing);
How can I handle the close event of a DocumentPane?
The code I used for this RegionAdapter is based off of http://blog.raffaeu.com/archive/2010/07/04/wpf-and-prism-tab-region-adapter-part-02.aspx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这里找到答案 http://avalondock.codeplex.com/discussions/231982?ProjectName=avalondock
我必须添加:
Found the answer here http://avalondock.codeplex.com/discussions/231982?ProjectName=avalondock
I had to add: