|
Group: Forum Members
Posts: 5,
Visits: 1
|
Angel -> thanks a lot for the quick reply....
Let me clarify what my goals are...
I have a WinForms form. I have created menus and toolbars by first creating NCommandContext objects, setting appropriate properties, adding these to the NMenuBar and NToolbar objects connected to the form and poof -> menus and toolbars that are bound to the NCommandContext objects.
Now I want to add a regular, everyday button to the form (not to a toolbar).
Using traditional Windows controls it might look something like...
Button b = new Button(); b.Text = "Foo"; myForm.Controls.Add(b);
What I want to do is the following (these properties do not exist, but this is my P-Code)
NCommand com = new NCommand(); com.Properties.Text = "Foo"; ....
NButton button = new NButton(); button.Command = com; // bind the button to the command -- does not exist
myForm.Controls.Add(button);
************* OR *****************
NCommand com = new NCommand(); com.Properties.Text = "Foo"; ...
myForm.Controls.Add(com); // and have com render as a button. Is this what you are suggesting in the first part of your response?
then in the app, when com.Properties.XXX are changed, those properties in the NButton instance also change. Basically a model/view pattern between the NCommand and the NButton.
This all works perfectly in menus and toolbars. I want a simple button. More specifically I want to *bind* an NCommand object to an NButton object.
....
I tried the NControlHostCommand option you suggested... public class NCommandButton : { public NCommandButton() { NButton b = new NButton(); SetControl(b); } }
... and ... private void Form1_Load(object sender, EventArgs e) { NCommandButton button = new NCommandButton(); button.Properties.Text = "Button"; Controls.Add(button.HostedControl); }
but the rendered button has no text, leading me to believe that the bindings between the NControlHostCommand and the HostedControl are not set up properly behind the scenes.
Thanks Jeff
|