silverlight - Command binding in code behind -


i trying bind command in code behind of custom control. control doesn't have viewmodel page going part of has one. view model has multiple commands defined new,save,delete against button clicks. since have create buttons programmatically have bind commands in code happening via xaml binding.

please note have bound commands in code following if defined in codebehind of control using following approach.

click.setcommand(newbutton, commandnew); 

but since present in viewmodel of containing page can't figure out way it. have employed following approach without success. although works binding of other properties defined in same view model!

  radbutton newbutton =  new radbutton(); // create new rad button   binding commandbinding = new binding(); //create command    commandbinding.path = new propertypath("commandnew");   click.setcommand(newbutton , commandbinding icommand);   buttontoolbar.items.add(newbutton ); 

any appreciated. thanks.

this issue has been sorted. in above code dynamically binding command should have been using following line of code.

newbutton.setbinding(radbutton.commandproperty, commandbinding); 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -