Usercontrol中的DataBinding

时间:2013-10-05 17:10:02

标签: c# user-controls windows-store-apps winrt-xaml

我有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之外时,应用就可以了。

0 个答案:

没有答案