2017-09-12 13 views
2

내 애플리케이션에 ViewModelLocator 패턴을 구현하려고하는데 ViewModel이 뷰에 연결되지 않았습니다. 나는 프리즘을 처음 접했고, 내가 여기에 무엇이든 놓치고 있다면 알려주지.프리즘 6의 ViewModelLocator가 작동하지 않습니다.

보기 :

<Window x:Class="WpfApp1.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:local="clr-namespace:WpfApp1" 
     xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Wpf" 
     prism:ViewModelLocator.AutoWireViewModel="True" 
     mc:Ignorable="d" 
     Title="MainWindow" Height="350" Width="525"> 
    <Grid> 
     <TextBlock Text="{Binding Message}" FontSize="36" /> 
    </Grid> 
</Window> 

뷰 모델 :

class MainWindowViewModel : BindableBase 
{ 
    string _message = "Hello World"; 
    public string Message 
    { 
     get { return _message; } 
     set { SetProperty<string>(ref _message, value); } 
    } 
} 

폴더 구조 :

enter image description here

+0

[프리즘 6.1 ViewModelLocator가 내 ViewModel을 인스턴스화하지 않습니다] (https://stackoverflow.com/questions/35792126/prism-6-1-viewmodellocator-doesnt-instantiate-my-viewmodel) – Haukinger

+0

당신의 복제본은 무엇입니까? 네임 스페이스와'ViewModelLocator'를 위해 설정된 규칙은 무엇입니까? – Haukinger

+0

''Window x : Class = "WpfApp1.MainWindow"''MainWindow'가'WpfApp1.Views' 네임 스페이스에있는 것처럼 보이지 않습니다 ... – Haukinger

답변

2

의 의견이 Views 네임 스페이스에 상주 있는지 확인하고 viewmodels ViewModels을에 로 나타났다.