Quantcast
Channel: AvalonDock
Viewing all articles
Browse latest Browse all 2690

New Post: AvalonDock and ContentControl

$
0
0
Hello!

I am using AvalonDock in a MVVM-based application.

This has some Viewmodels and loads the corresponding controls out of a datatemplate:
<Window.Resources>
        <ResourceDictionary>            
            <!--DataType for Viewmodel-->
            <DataTemplate  DataType="{x:Type local:MyControlVM}">
                <local:MyControl />
            </DataTemplate>
        </ResourceDictionary>
    </Window.Resources>

...

<avalondock:DockingManager>
            <avalondock:ResizingPanel Orientation="Vertical">
                    <!--UserControl in DocumentPane-->
                    <avalondock:DocumentPane>
                        <avalondock:DocumentContent>

                                <ContentControl Content="{Binding Path=MainWindow.MainWindowVM.MyControlVM, Source={x:Static app:App.Current}}" />

                        </avalondock:DocumentContent>
                 </avalondock:DocumentPane>
            </avalondock:ResizingPanel>
    </avalondock:DockingManager>
I am using this one
Content="{Binding Path=MainWindow.MainWindowVM.MyControlVM, Source={x:Static app:App.Current}}"
because of the binding problem (I have created a Dependency Property of the Viewmodel on my Mainwindow).

If I run the app, everything works fine, I can float the windows and the keep the binding (and DataTemplate).

But now my problem: if I float the DocumentContent (it's not docked in the MainWindow) and instantiate a new Viewmodel, it doesn't find the corresponding DataTemplate and shows the Result of the ToString()-Method.
Putting the resources in the Appl.xml doesn't help.

Any ideas how I can solve this issue?

Thanks a lot!
Joerg

Viewing all articles
Browse latest Browse all 2690

Trending Articles