Adding document windows from ItemsSource?

Docking/MDI for WPF Forum

Posted 7 years ago by Bryan Coon
Version: 12.2.0570
Avatar

Hi, I have a WPF Deep Zoom control that Im trying to play with in conjunction with the TabbedMdiContainer.

Basically, I have a ViewModel that has an observable collection the paths (strings) to the deep zoom files I want to see.   I was trying to bind the TabbedMdiContainer.ItemsSource prop to this collection, and have each of my deep zoom controls show up in its own document window.

But while ItemsSource is of type IEnumerable, I get an error that System.String cannot be converted to DocumentWindowContainer. 

Even if I I set the ItemTemplate to a DocumentWindow like this:

<docking:TabbedMdiContainer ItemsSource="{Binding DeepZooms}">
	<docking:TabbedMdiContainer.ItemTemplate>
		<DataTemplate>
			<docking:DocumentWindow Title="{Binding}" Description="Deep Zoom">
				<Controls:MultiScaleImage MaxZoom="8.0" Source="{Binding}" />
			</docking:DocumentWindow>
		</DataTemplate>
	</docking:TabbedMdiContainer.ItemTemplate>
</docking:TabbedMdiContainer>

 The error is the same....

I don't want to create an observable collection of DocumentWindow in my view model.  Am I not doing this the right way?  Can I do this, if so how?

Thanks!

Comments (3)

Answer - Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Bryan,

Sorry but what you are doing won't work.  You should never reference or name specific "container" objects in our product because they are dynamically created/destroyed as the docking layout changes.  Instead if you wish to use MVVM, please read the "MVVM Features" documentation topic.  It walks you through how to do things properly.


Actipro Software Support

Posted 7 years ago by Bryan Coon
Avatar

Hi, thanks for the response.  I did look at the MVVM features... and even dug into the example code- what exactly is that attached behavior for?  Do I need it (Im referring to DockSiteViewModelBehavior)?

I hope not.  Having to add an attached behavior and 3 other view model classes isn't what I had in mind.

And what if I want to have a auto hide left container, a TabbedMdiHost at top right and another at bottom right, with the bottom right container adding new DocumentWindows through my view model?  Can I just nest a DockSite there and have it done, kind of using DockSite as a single container within a more complicated parent DockSite?

Thanks!

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

You don't need the attached behavior but it takes care of some of the manual work required to open and position docking windows (described in the documentation topic), so it's handy to use.

You can nest DockSites with our product and probably do what you're thinking.  Just be sure that the nested DockSite is within a Workspace that is within the root DockSite (or a SplitContainer within it).


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.