Composite WPF

Dec 23, 2009 at 1:11 PM
Edited Dec 31, 2009 at 9:38 AM

Hi.
I'm trying to use AvalonDock in aplication builded with Composite WPF  - http://www.codeplex.com/CompositeWPF
But in present form of AvalonDock changing something in behavior of this control is almost impossible. So i changed a bit sources and i'd like to share.

Download link: http://bit.ly/4uhW0B

First off all I added some events to DockingManager:

	public event EventHandler<EventArgs<FlyoutPaneWindow>> FlyoutPaneWindowClosing;
        	public event EventHandler<EventArgs<FlyoutPaneWindow>> FlyoutPaneWindowPositionChanged;
        	public event EventHandler<EventArgs<DockableContent>> DockableContentClosed;

Aslo in Docking manager I created factory methods, like:

  protected virtual DocumentFloatingWindow CreateDocumentFloatingWindow(DocumentContent content)
        {
            return new DocumentFloatingWindow(this, content);
        }

or

protected virtual DockablePane CreateDockablePane()
        {
            return new DockablePane();
        }

Now you can for example extend DockingManager and providing your own class for DockableFloatingWindow, where you can disable not working correctly redocking after double mouse click on header.

 public class DockManager : DockingManager
    {
        public override DockableFloatingWindow CreateDockableFloatingWindow()
        {
            return new DockingWindow(this);
        }

        public override DockableFloatingWindow CreateDockableFloatingWindow(DockableContent content)
        {
            return new DockingWindow(this, content);
        }

        public override DockableFloatingWindow CreateDockableFloatingWindow(DockablePane pane)
        {
            return new DockingWindow(this, pane);
        }
    }


  public class DockingWindow : DockableFloatingWindow
    {
        public DockingWindow(DockingManager manager) : base(manager)
        {
        }

        public DockingWindow(DockingManager manager, DockableContent content) : base(manager, content)
        {
        }

        public DockingWindow(DockingManager manager, DockablePane dockablePane) : base(manager, dockablePane)
        {
        }

        protected override void Redock()
        {
            return;
        }
    }
You can aslo know when DockableContent is closed by subscribing to proper event, for example:
dockingManager.DockableContentClosed += OnDockingManagerDockableContentClosed;
  private void OnDockingManagerDockableContentClosed(object sender, AvalonDock.EventArgs<AvalonDock.DockableContent> e)
        {
            foreach (var region in RegionManager.Regions)
            {
                if(region.Views.Contains(e.Value.Content))
                {
                    region.Remove(e.Value.Content);
                }
            }
        }

I'm waiting for feedback.
If someone will by interested, I will be publishing progres of my work here.

 

Dec 30, 2009 at 6:29 PM

The link to your source is broken. Can you please post the code ? many thanks

Dec 31, 2009 at 9:36 AM
Edited Dec 31, 2009 at 9:37 AM

Sure: http://bit.ly/4uhW0B

Jan 5, 2010 at 4:56 PM

If you could provide some examples on using the AvalonDock in Prism project will certainly be a great help!  Thanks

 

Jan 29, 2010 at 11:14 AM
            m_regionManager.AddToRegion(Views.Main, view);

All that's needed to get AvalonDock and Prism working together is a new RegionAdapter. See http://johnpapa.net/silverlight/fill-my-prism-region-please/ for an example of how to implement the Adapter for Grids.

<ad:DockingManager x:Name="MainDockManager" DockPanel.Dock="Left">
    <Grid cal:RegionManager.RegionName="{x:Static const:Views.Main}" />
</ad:DockingManager>


 

Then in your Module, this is the xaml for a simple video view

 

<UserControl x:Class="MyView"
    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" 
    Height="300" Width="300">
    <ad:ResizingPanel>
        <ad:DockablePane>
            <ad:DockableContent Name="_mainFrame" Title="My video">
                <DockPanel>
                    <Button Height="23" Name="_playButton" Width="75" DockPanel.Dock="Bottom" Click="_playButton_Click">Play</Button>
                    <MediaElement Name="_mediaElement" LoadedBehavior="Manual" />                    
                </DockPanel>
            </ad:DockableContent>
        </ad:DockablePane>
    </ad:ResizingPanel>
</UserControl>

 

It is created as normal with the following command in C# from your module:

 

     m_regionManager.AddToRegion(Views.Main, view);