0
我在Windows Phone 8中有點新,在這個{Binding}的東西迷路了。我想知道這個按鈕commandparameter綁定怎麼樣?這個命令參數綁定到什麼地方?windows phone 8按鈕的commandparameter {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>
*「只能刪除它,因爲它什麼都不做」。*除非所需的命令參數是按鈕上顯示的影片。 – Will
@無論做什麼,設置DataContext =「{Binding}」都沒有影響,默認情況下,DataContext會自動從父項繼承,因此明確設置它將不起作用。重要的綁定是CommandParameter =「{綁定}」。 –
不,DataContext不會*流向按鈕的CommandParameter。因此,如果您需要通過CommandParameter將當前的DataContext內容傳遞到命令中,則必須**使用綁定。說它有「嚴格無效」是完全不正確的。自己嘗試一下。 – Will