I have a window in WPF based upon a viewmodel. The viewmodel includes a child viewmodel that can be switched at runtime. Each child viewmodel has its own commands. The parent view contains a ribbon with buttons that need to bind to the current child viewmodels commands. To switch views I use a content control in the parent view that uses data templates. Each possible child view is a user control that binds to the appropriate viewmodel (that bit works).
<!-- Switchable area -->
<ContentControl Content="{Binding ChildViewModel}">
<ContentControl.Resources>
<DataTemplate DataType="{x:Type vm:VersionsViewModel}">
<embeddable:VersionsView />
</DataTemplate>
<DataTemplate DataType="{x:Type vm:LockListViewModel}">
<embeddable:LockListView />
</DataTemplate>
</ContentControl.Resources>
</ContentControl>
So for example, one of my child viewmodels has a refresh command. I want this to appear in the main view in a ribbon button. I've tried setting the binding to the following XAML but it never binds so the command isn't called. What am I doing wrong?
<telerik:RadRibbonButton Size="Large"
Text="Refresh"
LargeImage="..\Images\Ribbon\32x32\Refresh.png"
Command="{Binding ChildView.RefreshCommand}"
telerik:KeyTipService.AccessText="R"/>
Elsewhere in the main view I have bindings for data that comes from the child viewmodel and works fine so I'm really confused! For example, this is the binding I use to get the title for the window.
Title="{Binding ChildViewModel.Title,FallbackValue='My System'}"
ChildView.
... against what the binding of your Title-property has the PathChildViewModel.
... – Florian Gl