0

这与这个问题有关

关闭文档的 MVVM 方式,可能会取消

我正在使用第三方库 (AvalonDock) 它有一个 CloseCommand 属性,如何使用 Caliburn 将此属性连接到 Action 方法?

使用香草 WPF 它可能看起来像这样

<ad:DockingManager
    DataContext="{Binding Manager}"
    DocumentsSource="{Binding Documents}">

    <ad:DockingManager.LayoutItemContainerStyle>
        <Style TargetType="{x:Type ad:LayoutItem}">
            <Setter Property="CloseCommand" Value="{Binding Model.CloseCommand}"/>
        </Style>
    </ad:DockingManager.LayoutItemContainerStyle>

</ad:DockingManager>
4

1 回答 1

1

If i understand you correctly, you can try this.

<ad:DockingManager cal:Message.Attach="[Event DocumentClosed] = [Action DockingManager_DocumentClosed($eventArgs)]" />

In your ViewModel

public void DockingManager_DocumentClosed(DocumentClosedEventArgs e)
        {
            Models.Documents.Document doc = e.Document.Content as Models.Documents.Document;
            DocumentSources.Remove(doc);
        }

You have several options from there.

ps: Models.Documents is a class, where my (document) collections are stored

于 2013-12-20T12:14:10.283 回答