2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.ComponentModel;
20 using System.Linq.Expressions;
22 namespace Tizen.NUI.Binding
24 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
25 [EditorBrowsable(EditorBrowsableState.Never)]
26 public static class BindableObjectExtensions
28 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
29 [EditorBrowsable(EditorBrowsableState.Never)]
30 public static void SetBinding(this BindableObject self, BindableProperty targetProperty, string path, BindingMode mode = BindingMode.Default, IValueConverter converter = null,
31 string stringFormat = null)
34 throw new ArgumentNullException(nameof(self));
35 if (targetProperty == null)
36 throw new ArgumentNullException(nameof(targetProperty));
38 var binding = new Binding(path, mode, converter, stringFormat: stringFormat);
39 self.SetBinding(targetProperty, binding);
42 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
43 [EditorBrowsable(EditorBrowsableState.Never)]
44 [ObsoleteAttribute(" ", false)]
45 public static void SetBinding<TSource>(this BindableObject self, BindableProperty targetProperty, Expression<Func<TSource, object>> sourceProperty, BindingMode mode = BindingMode.Default,
46 IValueConverter converter = null, string stringFormat = null)
49 throw new ArgumentNullException(nameof(self));
50 if (targetProperty == null)
51 throw new ArgumentNullException(nameof(targetProperty));
52 if (sourceProperty == null)
53 throw new ArgumentNullException(nameof(sourceProperty));
55 Binding binding = Binding.Create(sourceProperty, mode, converter, stringFormat: stringFormat);
56 self.SetBinding(targetProperty, binding);