In v1.3 we are in the process of generating code for automatic event registering, the same way WPF does when you build the project and it generates a "????.g.cs" file with a partial implementation of your code behind root class.
In 1.3 beta3 you still have to do it manually by getting a reference to the named control:
void OnPostInit()
{
CheckBox* cb = FindName<CheckBox>("CheckBox1");
cb->Checked() += MakeDelegate(this, &MyUserControl::CheckBox1_Checked);
//...
}
For the upcoming 1.3 beta4 we are preparing now, we will provide an overrideable funtion in the FrameworkElement that will alllow you to register events even on unnamed controls, in a way more similar how WPF does:
void Connect(BaseComponent* source, const NsChar* eventName, const NsChar* handlerName) override
{
if (String::Compare(eventName, "Checked") == 0 && String::Compare(handlerName, "CheckBox1_Checked") == 0)
{
CheckBox* element = NsStaticCast<CheckBox*>(source);
element->Checked() += MakeDelegate(this, &MyUserControl::CheckBox1_Checked);
}
}
In the final version we want to provide a tool that will generate that code automatically for you.