初学者教程中,我一直跟着说我应该在窗口中创建一个命名空间,如何为单个元素设置DataContext?
<Window ... xmlns:vm="clr-namespace:MyApp.ViewModels" />
,然后设置的DataContext这样,
<Window.DataContext>
<vm:MyViewModel />
</Window.DataContext>
但我不想在DataContext到适用于整个窗口。我想要不同的元素使用不同的上下文。
我的DataGrid中被定义一样,
<DataGrid ... DataContext="{Binding}" ItemsSource="{Binding Path=Queue}"
我想这DataContext="{Binding}"
位基本上采用“使用父上下文”,但我不能将其设置为vm:MyViewModel
就在那里?我不确定正确的语法,并且Visual Studio属性窗口在这件事上似乎很没用。
够简单......我想我是困惑的问题。谢谢! – mpen 2010-10-19 19:10:30