我有ListView
UserControl
:
<ListView x:Name="peopleListBox">
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<UserControls:ItemTemplateControl />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
UserControl
:
<UserControl
..........
d:DataContext="{d:DesignInstance Type=control:MainViewModel, IsDesignTimeCreatable=True}"
mc:Ignorable="d">
<UserControl.Resources>
<control:DataContextProxy x:Key="DataContextProxy" />
</UserControl.Resources>
<Grid>
<Button Content="Click" Command="{Binding Source={StaticResource DataContextProxy}, Path=DataSource.OpenCommand}"/>
</Grid>
</UserControl>
绑定不起作用。我认为Binding
存在问题,因为当我将UserControl
放在我的ListView
之外时,应用就可以了。