在 WPF 中:如何将 ItemsSource 循环的索引作为 CommandParameter 传递?
<ItemsControl ItemsSource="{Binding PageList}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button
Content="{Binding Name}"
Command="{Binding DataContext.ChangePageCommand, ElementName=Window}"
CommandParameter="INDEX OF ACTUAL ITEM AT ITEMSSOURCE GOES HERE" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
所以,我想要的是将按下的按钮编号传递给 Command 方法。
谢谢!