0
votes

I have a MainWindow in which i want to add my others Views. Users can open Mutliple number of different Views to the MainWindow.

So for adding all those Views(UserControls), which is the best control to use.

Current I am using Canvas, but its not supporting MVVM.

So how can i add multiple control.

This is what i have done till now

enter image description here

Note: The control should host multiple UserControl by the same time i should be able to drag One UserControl here and there in that control and then on a click on UserControl should bring it to Front(Focused), which i did in Canvas using ZIndex.

1
are this views esclusive? I mean, if I see one view, can I see also others?Tigran
ya, use should able to view all views in that controlKishore Kumar
A canvas seems like it should work. What do you mean that it doesn't support MVVM?Dan Busha
I am search for an better solution..Kishore Kumar
@KishoreJangid Nice window style, is there possible to get that style?John

1 Answers

1
votes

Proper MVVM solution migh be to use ItemsControl class and bind collection of view-models as an ItemsSource.

In DataTemplate of that ItemsControl, I would specify proper view for child view-models (sort of tool-window in your case).

<ItemsControl.ItemTemplate>
    <DataTemplate>
        <views:ToolWindow DataContext={Binding} />
    </DataTemplate>
</ItemsControl.ItemTemplate>

To achieve window-like behavior as on your picture I would specify custom panel based on Canvas which would allow drag and drop behavior.

<ItemsControl.ItemsPanel>
    <ItemsPanelTemplate>
        <panels:MyCustomMdiPanel />
    </ItemsPanelTemplate>
<ItemsControl.ItemsPanel>

I suppose that you have already working canvas solution.