WPFのコマンドをダブルクリックしますプログラムでバインドボタンは、私が<code>ListBox</code>次いる
<ListBox x:Name="SequencesFilesListBox" ItemsSource="{Binding SequencesFiles, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Foreground="DarkBlue" BorderBrush="Transparent" />
SequencesFiles
ItemsSource
がObservableCollection<Button>
であると定義します。
私は手動で次の関数を使用してコレクションに新しいButtons
を追加している:
private void AddSequenceToPlaylist(string currentSequence)
{
if (SequencesFiles.Any(currentFile => currentFile.ToolTip == currentSequence)) return;
var newSequence = new Button
{
ToolTip = currentSequence,
Background = Brushes.Transparent,
BorderThickness = new Thickness(0),
HorizontalAlignment = HorizontalAlignment.Stretch,
HorizontalContentAlignment = HorizontalAlignment.Stretch,
Content = Path.GetFileName(currentSequence),
Command = PlaylistLoadCommand,
CommandParameter = currentSequence,
};
SequencesFiles.Add(newSequence);
}
は、クリック時にクリック、ダブル、いない時にCommand
(PlaylistLoadCommand
)を呼び出すことが可能ですか?
をあなたのコマンドを起動するためにあなたの
Button
にInputBinding
を設定し、私は手動でコレクションに新しいボタンを追加している... *さて、あなたの問題があります。あなたはおそらくより簡単な方法であなたの目標を達成することができます。あなたは*なぜあなたがこれをやっているのか見直したいかもしれませんが、あなたの目標を達成するためのより良い、より多くのmvvm/wpf-ishの方法を尋ねるかもしれません。別の質問です。 – Willあなたは私の答えを投票できますか(バッジなど)? –