unity3d and MVVM Binding
Hi,
I have experience in WPF and tried to use "NoesisGUI-0.9.8.4060" in unity3d with Binding in XAML.
I've tried to extend a "Tic-Tac-Toe" sample to work with Binding (MVVM).
I've created small ViewModel with public property "MyTxt":
In "NoesisRegisterClasses.cs" file, inside "Register" method I've added this line
In "TicTacToe.cs" file, inside "Start" method, I've added this line:
In "MainWindow.xaml" I've changed (563) line to work with binding:
But, it seems that Binding isn't working or I did something wrong.
Please help
Thanks,
Maxim.
I have experience in WPF and tried to use "NoesisGUI-0.9.8.4060" in unity3d with Binding in XAML.
I've tried to extend a "Tic-Tac-Toe" sample to work with Binding (MVVM).
I've created small ViewModel with public property "MyTxt":
Code: Select all
public class MyVM : BaseComponent
{
private HandleRef swigCPtr;
// bindable prop
public string MyTxt { get; set; }
public static void Register()
{
BaseComponent.Extend_BaseComponent("MyVM", typeof(MyVM));
}
public MyVM(IntPtr cPtr, bool cMemoryOwn)
: base(cPtr, cMemoryOwn)
{
swigCPtr = new HandleRef(this, cPtr);
// Init bindable prop
MyTxt = "Hello World";
}
public MyVM()
: this(Noesis.Reflection.DoInstantiateExtend("MyVM"), true)
{
Noesis.Reflection.DoSetExtendHandle("MyVM", swigCPtr.Handle, this);
}
public override void Dispose()
{
lock (this)
{
if (swigCPtr.Handle != IntPtr.Zero)
{
if (swigCMemOwn)
{
swigCMemOwn = false;
Noesis.Reflection.DoDeleteExtend("MyVM", swigCPtr.Handle);
}
swigCPtr = new HandleRef(null, IntPtr.Zero);
}
GC.SuppressFinalize(this);
base.Dispose();
}
}
};
Code: Select all
MyVM.Register();
Code: Select all
this.mRoot.SetDataContext(new MyVM());
Code: Select all
<TextBlock x:Name="Title" Text="{Binding MyTxt}" ...
Please help
Thanks,
Maxim.
-
sfernandez
Site Admin
- Posts: 3154
- Joined:
Re: unity3d and MVVM Binding
Notifications from DataContext objects were not correctly implemented in v0.9.8 yet, but are working on current version.
We will release a new version soon with many improvements to Unity data binding integration, following the suggestions from all of you.
We will release a new version soon with many improvements to Unity data binding integration, following the suggestions from all of you.
Who is online
Users browsing this forum: Killian and 2 guests