c# - wpf commandtarget for routeduicommand with nested controls -


i have main window wich consist of fluidribbon control menu , statusbar. has content control load views (usercontrols).

im using routeduicommand's execute button events ribbon buttons. depending on ribbon buttons action want them executed in main window or in loaded view (usercontrol).

my problem when bind ribbonbutton command executed inside loaded usercontrol seams dosen't matter commandtarget binding usercontrol sender , source in executedroutedeventargs.

in particular case need actuall fluent.button can modify text , icon on button since kinda of toggle button wanna swith text open -> close -> open , same associated icons.

at creation of usercontrol binds command:

this.commandbindings.add(new commandbinding(commandlibrary.invoicecontrol_previewtoggle, onpreviewtoggle_command)); 

then have event:

private void onpreviewtoggle_command(object sender, executedroutedeventargs e) {     var button = e.source fluent.button; } 

then in main window got ribbonbutton:

<fluent:button x:name="previewtoggle_button" header="open" icon="/levscan.wpf.resources;component/icons/appbar.layer.perspective.up.png" largeicon="/levscan.wpf.resources;component/icons/appbar.layer.perspective.up.png" command="cmd:commandlibrary.invoicecontrol_previewtoggle" commandtarget="{binding elementname=previewtoggle_button}" canaddtoquickaccesstoolbar="false"/> 

and sender , e.source = usercontrol , e.originalsource seams focused element in usercontrol.

edit

found workaround solves issue target, can pass button commandparameter, works dont think solution becourse if need pass actuall parameter need working target.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -