0

Following is the section from My Shell:

        <StackPanel x:Name="stack" Orientation="Horizontal" Height="25" HorizontalAlignment="Right" Margin="0,4,0,0" Grid.Row="0">
            <Button DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type StackPanel}}, Path=DataContext}" Content="Back" prism:Click.Command="{Binding Path=GoBackCommand}"/>
            <Button DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type StackPanel}}, Path=DataContext}" Content="Forward" prism:Click.Command="{Binding Path=GoForwardCommand}"  Margin="10,0,0,0"/>
        </StackPanel>


        <ContentControl x:Name="ActionContent" prism:RegionManager.RegionName="{x:Static inf:RegionNames.WorkspaceRegion}" Grid.Row="1">
            <ContentControl.Template>
            <ControlTemplate TargetType="ContentControl" >                        
                        <Grid >
                        <Controls:RoundedBox/>                 
                        <ContentPresenter Margin="10,0,10,0" Content="{TemplateBinding Content}" />                          
                        </Grid>                       

                    <ControlTemplate.Triggers>
                    <Trigger Property="HasContent" Value="false">
                        <Setter Property="Visibility" Value="Collapsed" />
                    </Trigger>

                    <DataTrigger Binding="{Binding ElementName=stack}">
                            <Setter Property="DataContext" Value="{Binding RelativeSource={RelativeSource Self}, 
                            Path=Content.DataContext}" />
                        </DataTrigger>

                    </ControlTemplate.Triggers>

            </ControlTemplate>
        </ContentControl.Template>

In ContentControl views are injecting from Modules (using ribbon tab). I want two button inside StackPanel may use ViewModels (DataContext) of injected views, for backward and Forward navigation.

Please Help, thanks!

Amit K.S
  • 299
  • 3
  • 9

1 Answers1

0

I would start by having a good read at Prism Navigation Chapter,

and how to use the navigation journal.

Edit: I don't think you can do what you want directly in XAML, but i can see 2 workarounds:

  • Define the commands as global CompositeCommand in the shell viewmodel, then have your views reister and unregister their own implementations as they are navigated.
  • Define a new Region in wich the views can inject their own navigation buttons.

Hope this can help you.

Dtex
  • 2,593
  • 1
  • 16
  • 17
  • my problem is different what u thought. i want navigation buttons on shell which is common for all viewmodels from all modules, now question is that how these buttons get command (for navigation) from different viewmodels as these buttons are placed on shell, as views are binding on contentControl and button are placed in stackpanel – Amit K.S Jan 11 '14 at 06:54