ToolItemsSource example

Docking/MDI for WPF Forum

Posted 13 years ago by Stephen Tapper
Version: 11.1.0543
Avatar
I'm trying to throw together a sample project with just the basic for creating ToolWindows by binding objects to the ToolItemsSource property. I've been looking at the sample code that shows how the sample in the sample browser does it, but I'm missing something and not sure what. What happens right now is just that nothing shows up except for the static windows I describe in the xaml even though I'm binding objects to ToolItemsSource.

This is the xaml for the main window:

<docking:DockSite Name="dockSite" ToolItemsSource="{Binding}" >
    <docking:DockSite.ToolItemContainerStyle>
        <Style TargetType="docking:ToolWindow">
            <Setter Property="Title" Value="{Binding Name}"/>
        </Style>
    </docking:DockSite.ToolItemContainerStyle>
    <docking:Workspace>
        <docking:StandardMdiHost>
            <docking:DocumentWindow Title="Static docking window"/>
        </docking:StandardMdiHost>
    </docking:Workspace>
</docking:DockSite>

And then on the back end I do my binding like this:

 public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            ObservableCollection<Tool> tools = new ObservableCollection<Tool>();

            tools.Add(new Tool("Tool 1"));
            tools.Add(new Tool("Tool 2"));

            DataContext = tools;
        }
    }

    public class Tool
    {
        String name;

        public Tool(String name)
        {
            this.name = name;
        }

        public String Name
        {
            get { return name; }
        }
    }
There's probably something simple that I'm missing. Let me know if I need to explain something else or anything. Thanks for the help :)

Comments (1)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Stephen,

The ToolItemsSource will create the associated ToolWindows, but you are still responsible for opening them in the appropriate position. Our sample includes an attached behavior (the DockSiteViewModelBehavior class) on the DockSite, which opens the windows based on meta-data associated with the view.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.