-1

All samples found either address earlier version of prism or don't currently work. I am using Visual Studio 2015. I am specifically looking for an example of using ViewmodelLocator.AutoWireViewModel

Hellium
  • 7,206
  • 2
  • 19
  • 49
clef
  • 7
  • 1

1 Answers1

1

There is an offical example available at GitHub: https://github.com/PrismLibrary/Prism-Samples-Wpf/tree/master/HelloWorld

This sample uses Unity and ViewA uses the view model locatator to create an instance of ViewAViewModel: https://github.com/PrismLibrary/Prism-Samples-Wpf/blob/master/HelloWorld/Modules/ModuleA/Views/ViewA.xaml

<UserControl x:Class="ModuleA.Views.ViewA"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:prism="http://prismlibrary.com/"
             prism:ViewModelLocator.AutoWireViewModel="True">
    <Grid>
        <TextBlock Text="{Binding Title}" Foreground="Green" HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="Calibri" FontSize="24" FontWeight="Bold"></TextBlock>
    </Grid>
</UserControl>
mm8
  • 163,881
  • 10
  • 57
  • 88