c# - Can I send Clipboard in as Command Parameter? -


using mvvm have viewmodel implements commands. receive clipboard contents parameter , things it.

xaml:

    <button command="{binding path=clipboardaction}"              commandparameter="{binding someawesomecodeheretopasscurrentclipboard}" /> 

c#:

private void clipboardaction(object parameter) {     //parameter clipboard or clipboard data string[]  } 

is possible? if so, bind in xaml?

edit: work around far wire button click event , put in code behind glue.

    private void button_click(object sender, routedeventargs e) {         //manually send command object         string[] clipboard = clipboard.gettext().split(new char[] { '\n' });         var = sender button;         var viewmodel = (fooviewmodel)but.datacontext;         if (viewmodel.clipboardaction.canexecute(null)){             viewmodel.clipboardaction.execute(clipboard);         }     } 

since clipboard class provides clipboard data methods not properties, , binding can done properties only, no can't that.

edit

you may hack problem implementing custom converter don't think worthy:

public class clipboardconverter : ivalueconverter {     public object convert(object value, type targettype, object parameter,                    system.globalization.cultureinfo culture) {         return clipboard.getdata(value string);     }     public object convertback(object value, type targettype, object parameter,                    system.globalization.cultureinfo culture) {         throw new notimplementedexception();     } } 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -