3

我有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的应用程序工作正常。

4

0 回答 0