Manage tabs

Sep 10, 2014 at 10:08 AM
Hi everybody,

I'm using VS 2013. With C#, Caliburn Micro and WPF, I'm trying to reach this goal (see the "Simple MDI" example):
https://caliburnmicro.codeplex.com/wikipage?title=Screens%2c%20Conductors%20and%20Composition&referringTitle=Documentation

Instead of a DockPanel to contain the variuos tabs, I've now a DocumentGroup. How can I implement a logic like the one in the example? Respecting the MVVM, how can I do this? I'm stuck guys.. I'm a newbie! :)
Coordinator
Sep 11, 2014 at 3:36 PM
Hi pieruz,

Just download the source code and take a look at any of the two sample projects using this library.
If you open for example, the Samples/WPFSample project, you'll see MainView.xaml which contains a DocumentGroup called Items. The name has special meaning here as it uses Caliburn.Micro's convention based model. So Items means that the control will be bound to the Items property of the viewmodel, which is MainViewModel in this case. Items will contain the usersontrols you want to show on document panels.
In MainView.xaml.cs you can see the code calling the New() method of the viewmodel when the user presses the new button. It will actually call MainViewModel.New(), which creates a new DocumentViewModel object and activates it using ActivateItem. The DocumentGroup will create a new tab and show a DocumentView on the new panel.
So, if you follow the naming conventions Caliburn.Micro is based on, you only have to write those 2 lines of code you find in MainViewModel.cs and MainView.xaml.cs. (And you can forget 1 of them if you use my other package called Caliburn.Micro.FrameworkContentElement which can help you to bind a viewmodel's method directly to a DevExpress button without the need of a code-behind file.)

Regards,
Peter
Oct 30, 2014 at 3:49 AM
pjenei wrote:
Hi pieruz,

Just download the source code and take a look at any of the two sample projects using this library.
If you open for example, the Samples/WPFSample project, you'll see MainView.xaml which contains a DocumentGroup called Items. The name has special meaning here as it uses Caliburn.Micro's convention based model. So Items means that the control will be bound to the Items property of the viewmodel, which is MainViewModel in this case. Items will contain the usersontrols you want to show on document panels.
In MainView.xaml.cs you can see the code calling the New() method of the viewmodel when the user presses the new button. It will actually call MainViewModel.New(), which creates a new DocumentViewModel object and activates it using ActivateItem. The DocumentGroup will create a new tab and show a DocumentView on the new panel.
So, if you follow the naming conventions Caliburn.Micro is based on, you only have to write those 2 lines of code you find in MainViewModel.cs and MainView.xaml.cs. (And you can forget 1 of them if you use my other package called Caliburn.Micro.FrameworkContentElement which can help you to bind a viewmodel's method directly to a DevExpress button without the need of a code-behind file.)

Regards,
Peter
Hi Peter,

I tried your WPFSample1 program but it give me an error when i tried to drag the new DocumentView created by the 'New' button. I have tried recompile the library project with DX 13.2 and 14.1.

Error:

An unhandled exception of type 'System.InvalidOperationException' occurred in WindowsBase.dll

Additional information: Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead.