Page 1 of 1

SetDataContext in 1.2 for Unity

Posted: 12 Mar 2015, 21:20
by jeroenvdv
Hi,

I'm trying to get 1.2 for Unity to work with binding to my viewmodel, but nothing seem to work anymore.

Previously, I would use this:
ModelView _modelView = new ModelView(_manager);
NoesisGUIPanel noesisGUI = GetComponent<NoesisGUIPanel>();
Noesis.Grid grid = noesisGUI.GetRoot<Noesis.Grid>();
grid.SetDataContext (_modelView);
Now:
- "GetRoot" doesn't work anymore (replaced by GetContent? MonoDevelop doesn't recognize GetContent but Unity compiler does...)
- "SetDataContext" is recognized by MonoDevelop, but Unity compiler doesn't accept this.

Help!?

Re: SetDataContext in 1.2 for Unity

Posted: 12 Mar 2015, 23:53
by sfernandez
Hi,

Yes, 1.2 API tries to follow WPF API as much as possible, so we had to change lots of things. The most important changes are remarked in the changelog.

The code you posted should look like this now:
ModelView _modelView = new ModelView(_manager);
NoesisGUIPanel noesisGUI = GetComponent<NoesisGUIPanel>();
Noesis.Grid grid = (Noesis.Grid)noesisGUI.GetContent();
grid.DataContext = _modelView; 
I guess if you fix all compiler errors and Sync your MonoDevelop project, it would recognize the new API correctly.