DataBinding of CustomControl didn't work in Unity3d
Posted: 08 Apr 2019, 13:33
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")); }
}
}