1
私が行っているピボットアイテムのインデックスを取得します。
私はしばらくの間検索しましたが、ビュー内のイベントを使用し、MVVM-Lightを使用してViewModelにメッセージを送信するようないくつかのソリューションを考えることができます。しかし、私はむしろそれをやりたいのですが、私はむしろこの現在の実装に固執したいと思います。ピボットコントロールMVVM-Light-EventToCommand SelectedIndexが前のインデックスを送信
すべてのヘルプは
私のXAMLを高く評価されています
<controls:Pivot x:Name="ContentPivot" Margin="12,0,12,0">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<cmd:EventToCommand Command ="{Binding SelectSlideCommand}"
CommandParameter="{Binding SelectedIndex, ElementName=ContentPivot}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<controls:PivotItem x:Name="PivotItem0" Header="0">
<Image Source="{Binding ViewingSlides[0].Path}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</controls:PivotItem>
<controls:PivotItem x:Name="PivotItem1" Header="1">
<Image Source="{Binding ViewingSlides[1].Path}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</controls:PivotItem>
<controls:PivotItem x:Name="PivotItem2" Header="2">
<Image Source="{Binding ViewingSlides[2].Path}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</controls:PivotItem>
</controls:Pivot>
とC#:
public RelayCommand<int> SelectSlideCommand;
SelectSlideCommand = new RelayCommand<int>((pivotItem) => SelectSlideAction(pivotItem));
void SelectSlideAction(int parameter)
{
currentIndex = parameter;
UpdateViewingSlides();
Debug.WriteLine("SelectSlideAction: " + parameter);
}
ありがとう!私はすでにSelectedItemプロパティをバインドしようとしましたが、TwoWayバインディングモードについてはわかりませんでした。それはすべて今働く!ありがとうございました – Raymen
@RaymenScholtenトウイングバインディングを使用すると、ViewModelから表示するアイテムと逆のアイテムを選択できます。その非常に便利なこのシナリオでは.. – Ankesh