Using MVVM I have a ViewModel that implements commands. I would like to get the contents of the clipboard as a parameter and do something with it.
XAML:
<Button Command="{Binding Path=ClipBoardAction}"
CommandParameter="{Binding SomeAwesomeCodeHereToPassCurrentClipboard}" />
WITH#:
private void ClipBoardAction(object parameter) {
}
Is it possible? If so, what am I getting attached to in XAML?
EDIT : work so far - just connect the button to the Click event and paste the code behind the glue.
private void Button_Click(object sender, RoutedEventArgs e) {
string[] clipboard = Clipboard.GetText().Split(new Char[] { '\n' });
var but = sender as Button;
var viewModel = (FooViewModel)but.DataContext;
if (viewModel.ClipBoardAction.CanExecute(null)){
viewModel.ClipBoardAction.Execute(clipboard);
}
}
source
share