如何在LayoutAnchorable AvalonDock 2中放置窗口实例 [英] How to place instance of window in LayoutAnchorable AvalonDock 2

查看:71
本文介绍了如何在LayoutAnchorable AvalonDock 2中放置窗口实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将WPF C#应用程序(不是MVVM)中的AvalonDock从1.3升级到2.0.在1.3中,我能够放置自定义窗口,只要使用了DockableContent:XAML:

I'm upgrading AvalonDock in a WPF C# application (not MVVM) from 1.3 to 2.0. In 1.3 I was able to place custom windows as long as used DockableContent: XAML:

<!--<Window-->
<ad:DockableContent   x:Class="Test.JournalWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock" 
        xmlns:local="clr-namespace:Test"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"

        Loaded="Journal_Loaded" StateChanged="Journal_StateChanged"
        Title="Journal" Icon = "Resources/journalLog.ico" HideOnClose="True" Height="300" Width="Auto">

    <ad:DockableContent.Resources>
      </ad:DockableContent.Resources>

                <Grid>  </Grid>
</ad:DockableContent>
<!--</Window>-->

后面的代码:

public partial class JournalWindow : DockableContent
    {
        public JournalWindow()
        {
            InitializeComponent();
        }

MainWindow中显示实例化元素的代码:

Code in MainWindow to display instantited element:

JournalWindow journalWindow;
 journalWindow = new JournalWindow()
            {
                Name = nameJournalWindow,
                Title = "Journal"
            };

            journalWindow.IsCloseable = true;
            journalWindow.HideOnClose = true;
            journalWindow.Show(dockManager);

如何使用AvalonDock 2在LayoutAnchorable或其他布局元素(以前称为DockableContent)中放置和显示JournalWindow实例?

How to place and show instance of JournalWindow in LayoutAnchorable or other layout element (previously as DockableContent) using AvalonDock 2 ?

推荐答案

AvalonDock在新版本中进行了很多更改.在AD 2.0中,您有两种选择:1)最简单的方法是创建一个标准的UserControl(在您的情况下是从UserControl而不是DockableContent派生的JournalWindow)并将该控件放入LayoutAnchorable(作为其Content).示例代码:

AvalonDock is changed a lot with new version. In AD 2.0 you have two option: 1) The simplest one is to create a standard UserControl (in your case JournalWindow derived from UserControl instead of DockableContent) and put the control inside the LayoutAnchorable (as its Content). Sample code:

<UserControl x:Class="Test.JournalWindow" ...>
...
</UserControl>

<LayoutAnchorable Title="My Journal Window">
   <testNamespace:JournalWindow/>
</LayoutAnchorable>

2)推荐的一种方法是使用MVVM方法,为此,我将您带到附加到AvalonDock库的示例项目MVVMTestApp: http://avalondock.codeplex.com/downloads/get/558780

2) The recommended one is to use a MVVM approach and for this I'd point you to the sample project MVVMTestApp attached to AvalonDock library: http://avalondock.codeplex.com/downloads/get/558780

Ado

这篇关于如何在LayoutAnchorable AvalonDock 2中放置窗口实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆