wpf - Why MenuItem doesn't send specified parameters but Button send -
<menuitem command="local:commandlibrary.registerservicecommand"> <menuitem.commandparameter> <multibinding converter="{staticresource traywindowviewmodelconverterresource}"> <multibinding.bindings> <binding elementname="me" /> <binding fallbackvalue="parser" /> </multibinding.bindings> </multibinding> </menuitem.commandparameter> </menuitem> public class traywindowviewmodelconverter : imultivalueconverter { public object convert(object[] values, type targettype, object parameter, cultureinfo culture) { var viewmodel = new window1viewmodel(); foreach (var obj in values) { if (obj window) viewmodel.caller = obj window; else if (obj string) viewmodel.servicename = obj.tostring(); } return viewmodel; } public object[] convertback(object value, type[] targettypes, object parameter, cultureinfo culture) { throw new notimplementedexception(); } }
button cammand same menuitem. when debug converter menuitem, values parameter contains 2 object: dependencyproperty.unsetvalue (i'm not aware what's this) , mycontextmenu object.
and how can pass sometype parameter? thanks
menuitems exist in popups outside main visual tree , don't have same name scope surrounding elements, button. when trying bind, elementname binding can't resolve because "me" element outside menuitem's name scope.
Comments
Post a Comment