DataGrid にこの goto 機能があります。この機能は、ViewModel やコード ビハインドから除外したいので、次の添付ファイルは完璧かもしれませんが...
ユーザーが行 (アイテム) 番号を入力し、ユーザーが GotoButton をクリックすると、アイテムが表示されます。
<Grid>
<TextBox x:Name="GotoTextbox" Text="{Binding GotoLineNumber, UpdateSourceTrigger=PropertyChanged}" />
<Button Name="GotoButton" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<helpers:TargetedTriggerActionGotoButton TargetObject="{Binding ElementName=GenericDataGrid}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</Grid>
これが TargetedTriggerAction クラスです。
public class TargetedTriggerActionGotoButton : TargetedTriggerAction<DataGrid>
{
protected override void Invoke(object parameter)
{
this.Target.SelectedGridItem = GotoLineNumber - 1;
this.Target.SelectedGridIndex = GotoLineNumber.GetValueOrDefault() - 1;
}
}
どうにかして GotoTextbox からテキストを渡したいのですが、できるバインディングはありますか? どうすればこれを達成できますか?