[NUI]Add xaml support for nui and nui xaml test sample (#230)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / XamlBinding / PaddingElement.cs
1 namespace Tizen.NUI.Binding
2 {
3         static class PaddingElement
4         {
5                 public static readonly BindableProperty PaddingProperty =
6                         BindableProperty.Create(nameof(IPaddingElement.Padding), typeof(Thickness), typeof(IPaddingElement), default(Thickness),
7                                                                         propertyChanged: OnPaddingPropertyChanged,
8                                                                         defaultValueCreator: PaddingDefaultValueCreator);
9
10                 static void OnPaddingPropertyChanged(BindableObject bindable, object oldValue, object newValue)
11                 {
12                         ((IPaddingElement)bindable).OnPaddingPropertyChanged((Thickness)oldValue, (Thickness)newValue);
13                 }
14
15                 static object PaddingDefaultValueCreator(BindableObject bindable)
16                 {
17                         return ((IPaddingElement)bindable).PaddingDefaultValueCreator();
18                 }
19
20                 public static readonly BindableProperty PaddingLeftProperty =
21                         BindableProperty.Create("PaddingLeft", typeof(double), typeof(IPaddingElement), default(double),
22                                                                         propertyChanged: OnPaddingLeftChanged);
23
24                 static void OnPaddingLeftChanged(BindableObject bindable, object oldValue, object newValue)
25                 {
26                         var padding = (Thickness)bindable.GetValue(PaddingProperty);
27                         padding.Left = (double)newValue;
28                         bindable.SetValue(PaddingProperty, padding);
29                 }
30
31                 public static readonly BindableProperty PaddingTopProperty =
32                         BindableProperty.Create("PaddingTop", typeof(double), typeof(IPaddingElement), default(double),
33                                                                         propertyChanged: OnPaddingTopChanged);
34
35                 static void OnPaddingTopChanged(BindableObject bindable, object oldValue, object newValue)
36                 {
37                         var padding = (Thickness)bindable.GetValue(PaddingProperty);
38                         padding.Top = (double)newValue;
39                         bindable.SetValue(PaddingProperty, padding);
40                 }
41
42                 public static readonly BindableProperty PaddingRightProperty =
43                         BindableProperty.Create("PaddingRight", typeof(double), typeof(IPaddingElement), default(double),
44                                                                         propertyChanged: OnPaddingRightChanged);
45
46                 static void OnPaddingRightChanged(BindableObject bindable, object oldValue, object newValue)
47                 {
48                         var padding = (Thickness)bindable.GetValue(PaddingProperty);
49                         padding.Right = (double)newValue;
50                         bindable.SetValue(PaddingProperty, padding);
51                 }
52
53                 public static readonly BindableProperty PaddingBottomProperty =
54                         BindableProperty.Create("PaddingBottom", typeof(double), typeof(IPaddingElement), default(double),
55                                                                         propertyChanged: OnPaddingBottomChanged);
56
57                 static void OnPaddingBottomChanged(BindableObject bindable, object oldValue, object newValue)
58                 {
59                         var padding = (Thickness)bindable.GetValue(PaddingProperty);
60                         padding.Bottom = (double)newValue;
61                         bindable.SetValue(PaddingProperty, padding);
62                 }
63         }
64 }