windows phone 8按钮的命令参数{binding}

时间:2013-10-02 11:53:03

标签: windows-phone-7 windows-phone-8 windows-phone

我在Windows Phone 8中有点新,并且迷失在这个{Binding}中。我想知道这个按钮命令参数是如何绑定的?这个命令参数绑定到什么?

   <data:MoviesByCategory x:Key="movies"/>
    <data:MoreCommand x:Key="moreCommand" />
 <phone:LongListSelector x:Name="codeMovies" IsGroupingEnabled="true"
                                      ItemsSource="{StaticResource movies}"
                                      ListHeaderTemplate="{StaticResource movieListHeader}"
                                      GroupHeaderTemplate="{StaticResource movieGroupHeader}"
                                      ItemTemplate="{StaticResource movieItemTemplate}"
                                      JumpListStyle="{StaticResource MoviesJumpListStyle}"
                                      toolkit:TiltEffect.IsTiltEnabled="True">

                <!-- The group footer template, for groups in the main list -->
                <phone:LongListSelector.GroupFooterTemplate>
                    <DataTemplate>
                        <Button DataContext="{Binding}" Content="{Binding GetMore}"
                                Command="{StaticResource moreCommand}" CommandParameter="{Binding}"/>
                    </DataTemplate>
                </phone:LongListSelector.GroupFooterTemplate>

1 个答案:

答案 0 :(得分:1)

使用{Binding}将绑定到当前的DataContext,因此可以删除设置DataContext="{Binding}",因为它什么都不做。
由于CommandParameter="{Binding}"位于GroupFooterTemplate中,因此dataContext将成为您的影片组,因此它将是CommandParameter绑定到的内容。