2016-05-30 14 views
1

私はここで何か間違っていると確信していますが、モジュールに定義されたビューにAutowireViewModelアタッチプロパティを設定すると、ビューモデルを自動配線できません。インスタンス化されたビューモデルは表示されません。私のサンプルプロジェクトはgithubのであるプリズムモジュール内でAutowireViewModelが機能しない

<UserControl x:Class="MainModule.ToolbarWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     xmlns:mvvm="clr-namespace:Microsoft.Practices.Prism.Mvvm;assembly=Microsoft.Practices.Prism.Mvvm.Desktop" 
     mvvm:ViewModelLocator.AutoWireViewModel="True" 
     mc:Ignorable="d" 
     d:DesignHeight="300" d:DesignWidth="300"> 
<StackPanel> 
    <Label>Test</Label> 
    <Label Content="{Binding Name}"></Label> 
</StackPanel> 

https://github.com/rohits79/PrismAutoWire/tree/master/Prism%20App/MainModule

あなたは名前空間が間違っているんだhttps://github.com/rohits79/PrismAutoWire/blob/master/Prism%20App/Prism%20App/Bootstrapper.cs#L34

+0

でもう必要ありませんがItemsControlにのItemTemplateにに使用されるユーザーコントロールですか? – Clemens

+0

いいえ、githubのソースコードを見てください –

答えて

3

でハードコードされたパスを無視してください(下記参照)。

namespace MainModule 

[...]

public partial class ToolbarWindow 

ビューでは、デフォルトの解像度スキームを変更したくない場合はWhatever.ViewsWhatever.ViewModelsにおけるビューモデルに存在しています。

ToolbarWindowMainModule.Viewsに移動してください。あなたはいいです。ところで

IViewがプリズム6

+0

これは私のためのトリックでした。私はSomething.ViewとSomething.ViewModelという名前空間を持っていたので、AutoWireは動作しませんでした。 ViewsとViewModelsにそれらを複数化すると、成功しました! –

関連する問題