Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: Prism 5 - Using the ViewModelLocator on a UserControl?...

$
0
0
Unity 3.x

Hi,

I can use the ViewModelLocator in the Shell Window, but how do you get it to work on a UserControl that's inside a Project Library that will be injected into the Shell Window?
<Fluent:RibbonWindow 
    x:Class="NathsarTS.Master.Views.Shell"
    x:Name="NatsarTurahStudyMaster" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:prism="http://www.codeplex.com/prism" 
    xmlns:common="clr-namespace:NathsarTS.Common.Shared;assembly=NathsarTS.Common"
    xmlns:Fluent="clr-namespace:Fluent;assembly=Fluent"
    xmlns:Mvvm="clr-namespace:Microsoft.Practices.Prism.Mvvm;assembly=Microsoft.Practices.Prism.Mvvm.Desktop"
    Mvvm:ViewModelLocator.AutoWireViewModel="True"
    Title="Natsar Turah Study Master" Height="768" Width="1024" WindowStartupLocation="CenterScreen" WindowState="Maximized"
    ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto">
    <DockPanel LastChildFill="True" x:Name="ShellContentGrid">
        <ContentControl 
            DockPanel.Dock="Top"
            x:Name="ShellContent" 
            prism:RegionManager.RegionName="{x:Static common:RegionNames.ActionRegion}">

        </ContentControl>

        <ItemsControl prism:RegionManager.RegionName="{x:Static common:RegionNames.MainRegion}" DockPanel.Dock="Top"/>
    </DockPanel>
</Fluent:RibbonWindow>
I'm injecting UserControl:FluentRibbonView into the ActionRegion. Is it best to use the ShellViewModel for all the actions for the UserControl:FluentRibbonView instead of trying to locate another ViewModel?

But, I would like to use the ViewModelLocator in other parts of the Application when I inject views from a Project Library without using Code-Behind or UserControl Resource.

Because, most of the time I use parameterized constructors.

Thanks!...

Viewing all articles
Browse latest Browse all 1878

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>