[NUI] Add ValueGetter to BindableObject
authorFang Xiaohui <xiaohui.fang@samsung.com>
Mon, 18 Oct 2021 07:34:14 +0000 (15:34 +0800)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Thu, 11 Nov 2021 06:23:09 +0000 (15:23 +0900)
src/Tizen.NUI/src/public/XamlBinding/BindableObject.cs
src/Tizen.NUI/src/public/XamlBinding/BindableProperty.cs

index 893e0aa..6a0a2f8 100755 (executable)
@@ -188,9 +188,9 @@ namespace Tizen.NUI.Binding
             if (property == null)
                 throw new ArgumentNullException(nameof(property));
 
-            if (!IsBinded && property.DefaultValueCreator != null)
+            if (!IsBinded && property.ValueGetter != null)
             {
-                return property.DefaultValueCreator(this);
+                return property.ValueGetter(this);
             }
 
             BindablePropertyContext context = property.DefaultValueCreator != null ? GetOrCreateContext(property) : GetContext(property);
@@ -860,7 +860,11 @@ namespace Tizen.NUI.Binding
             {
                 context = CreateAndAddContext(property);
             }
-            else if (property.DefaultValueCreator != null)
+            else if (property.ValueGetter != null)
+            {
+                context.Value = property.ValueGetter(this); //Update Value from dali
+            }//added by xiaohui.fang
+            else if (property.DefaultValueCreator != null) //This will be removed in the future.
             {
                 context.Value = property.DefaultValueCreator(this); //Update Value from dali
             }//added by xb.teng
index 7db88be..6ae80e9 100755 (executable)
@@ -196,6 +196,7 @@ namespace Tizen.NUI.Binding
             BindingChanging = bindingChanging;
             IsReadOnly = isReadOnly;
             DefaultValueCreator = defaultValueCreator;
+            ValueGetter = defaultValueCreator;
 
             Dictionary<string, BindableProperty> nameToBindableProperty;
             bindablePropertyOfType.TryGetValue(declaringType, out nameToBindableProperty);
@@ -310,6 +311,8 @@ namespace Tizen.NUI.Binding
 
         internal CreateDefaultValueDelegate DefaultValueCreator { get; }
 
+        internal CreateDefaultValueDelegate ValueGetter { get; }
+
         internal BindingPropertyChangedDelegate PropertyChanged { get; private set; }
 
         internal BindingPropertyChangingDelegate PropertyChanging { get; private set; }