Sunday 15 May 2011

c# - WPF: Routing usercontrol command to Mainwindow -



c# - WPF: Routing usercontrol command to Mainwindow -

i must confess have problems understanding way wpf works. have usercontrol bottomcontrol nested in mainwindow. if button in bottomcontrol clicked want changes in mainwindow (changing content of textbox example) occur.

the easy thing phone call public procedure in click_event not quite elegant. got far utilize routedcommands.

public static readonly routedcommand bottomgridresize = new routedcommand();

in xaml of usercontrol

<button style="{staticresource transparentbutton}" command="{x:static local:commands.bottomgridresize}" >

in code of mainwindow

void bottomgridresize_canexecute(object sender, canexecuteroutedeventargs e) { e.canexecute = true; } void bottomgridresize_executed(object sender, executedroutedeventargs e) { \\do stuff }

obviously mainwindow can't utilize these events because ist doesn't recognize them. missing?

any help much appreciated

jon

just understanding: have bottomcontrol button , when button clicked there should happen in mainwindow. why not create dependencyproperty of type icommand in bottomcontrol , bind button. if can bind command of mainviewmodel dp.

<uc:bottomcontrol mydpcommand="{binding mymainviewmodelcommand}" />

c# wpf xaml command routedcommand

No comments:

Post a Comment