DataBinding of CustomControl didn't work in Unity3d
I writed a custom control with some DependencyProperty.
I created a databing when i used this control.
It works fine on vs blend,but didn't work in Unity3d. but I am able to bind some data to system controll such as Image,Label successfully. I have no idea if there is any woring operation!
Code: Select all
public class UIImage : Panel{
public static readonly DependencyProperty SourceProperty =DependencyProperty.Register("Source", typeof(Uri), typeof(UIImage), new FrameworkPropertyMetadata(PropertyChangedCallback));
public Uri Source {
get { return GetValue(SourceProperty) as Uri; }
set { SetValue(SourceProperty, value); }
}
}
Code: Select all
<nc:UIImage x:Name="BindImg" Height="166" Canvas.Left="1086" Canvas.Top="175" Width="156" Source="{Binding MyURI, Mode=OneWay}"/>
Code: Select all
public class VMMMMMMM : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private Uri uri;
public Uri MyURI
{
get { return uri; }
set { uri = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("MyURI")); }
}
}
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: DataBinding of CustomControl didn't work in Unity3d
I was able to reproduce the problem, there is a bug in our code when getting the value from a VieModel's Uri property.
Could you please report it in our bugtracker?
In the meantime as a workaround you can define the ViewModel's property as a string, then the binding will work fine.
Could you please report it in our bugtracker?
In the meantime as a workaround you can define the ViewModel's property as a string, then the binding will work fine.
Re: DataBinding of CustomControl didn't work in Unity3d
ok! I did it. If use ViewModel's property as a string to insted ,and it works fineI was able to reproduce the problem, there is a bug in our code when getting the value from a VieModel's Uri property.
Could you please report it in our bugtracker?
In the meantime as a workaround you can define the ViewModel's property as a string, then the binding will work fine.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 19 guests