【发布时间】:2017-05-11 07:31:35
【问题描述】:
进入 MainWindow.xaml 我有:
<Window x:Class="LayoutMVVM.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"
mc:Ignorable="d"
ResizeMode="NoResize"
xmlns:local="clr-namespace:LayoutMVVM"
xmlns:veiwmodels="clr-namespace:LayoutMVVM.ViewModels"
xmlns:views="clr-namespace:LayoutMVVM.Views"
Title="Layout" Height="750" Width="650">
我正在绑定 dataContext 到 Windows.Resources:
<Window.Resources>
<DataTemplate x:Name="SettingsTemp" DataType="{x:Type veiwmodels:SettingsModel}">
<views:SettingsView DataContext="{Binding}" />
</DataTemplate>
</Window.Resources>
但是当我的其他模型和视图位于以下子文件夹中时:
我做不到:
<DataTemplate x:Name="OpenTemp" DataType="{x:Type ViewModels:Open.OpenModel}">
<views:Open.OpenView DataContext="{Binding}" />
</DataTemplate>
或 LayoutMVVM.ViewModels.Open.OpenModel
或 LayoutMVVM/ViewModels/Open/OpenModel
【问题讨论】:
标签: wpf xaml mvvm namespaces viewmodel