[NUI] Merge Button action state and support experimental theme by profile. (#1525)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / DropDown.cs
1 /*
2  * Copyright(c) 2019 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 using System;
18 using System.Collections.Generic;
19 using Tizen.NUI.BaseComponents;
20 using System.ComponentModel;
21 using Tizen.NUI.Binding;
22
23 namespace Tizen.NUI.Components
24 {
25     /// <summary>
26     /// DropDown is one kind of common component, a dropdown allows the user click dropdown button to choose one value from a list.
27     /// </summary>
28     /// <since_tizen> 6 </since_tizen>
29     /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
30     [EditorBrowsable(EditorBrowsableState.Never)]
31     public class DropDown : Control
32     {
33         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
34         [EditorBrowsable(EditorBrowsableState.Never)]
35         public static readonly BindableProperty ListPaddingProperty = BindableProperty.Create(nameof(ListPadding), typeof(Extents), typeof(DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
36         {
37             var instance = (DropDown)bindable;
38             if (newValue != null)
39             {
40                 instance.listPadding.CopyFrom((Extents)newValue);
41                 instance.UpdateDropDown();
42             }
43         },
44         defaultValueCreator: (bindable) =>
45         {
46             var instance = (DropDown)bindable;
47             return instance.listPadding;
48         });
49         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
50         [EditorBrowsable(EditorBrowsableState.Never)]
51         public static readonly BindableProperty SelectedItemIndexProperty = BindableProperty.Create(nameof(SelectedItemIndex), typeof(int), typeof(DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
52         {
53             var instance = (DropDown)bindable;
54             if (newValue != null)
55             {
56                 int selectedItemIndex = (int)newValue;
57                 if (selectedItemIndex == instance.selectedItemIndex || instance.adapter == null || selectedItemIndex < 0 || selectedItemIndex >= instance.adapter.GetItemCount())
58                 {
59                     return;
60                 }
61                 instance.SetListItemToSelected((uint)selectedItemIndex);
62             }
63         },
64         defaultValueCreator: (bindable) =>
65         {
66             var instance = (DropDown)bindable;
67             return instance.selectedItemIndex;
68         });
69         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
70         [EditorBrowsable(EditorBrowsableState.Never)]
71         public static readonly BindableProperty ListMarginProperty = BindableProperty.Create(nameof(ListMargin), typeof(Extents), typeof(DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
72         {
73             var instance = (DropDown)bindable;
74             if (newValue != null)
75             {
76                 instance.listMargin.CopyFrom((Extents)newValue);
77                 instance.UpdateDropDown();
78             }
79         },
80         defaultValueCreator: (bindable) =>
81         {
82             var instance = (DropDown)bindable;
83             return instance.listMargin;
84         });
85         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
86         [EditorBrowsable(EditorBrowsableState.Never)]
87         public static readonly BindableProperty ListRelativeOrientationProperty = BindableProperty.Create(nameof(ListRelativeOrientation), typeof(ListOrientation), typeof(DropDown), ListOrientation.Left, propertyChanged: (bindable, oldValue, newValue) =>
88         {
89             var instance = (DropDown)bindable;
90             if (newValue != null)
91             {
92                 instance.listRelativeOrientation = (ListOrientation)newValue;
93                 instance.UpdateDropDown();
94             }
95         },
96         defaultValueCreator: (bindable) =>
97         {
98             var instance = (DropDown)bindable;
99             return instance.listRelativeOrientation;
100         });
101         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
102         [EditorBrowsable(EditorBrowsableState.Never)]
103         public static readonly BindableProperty SpaceBetweenButtonTextAndIconProperty = BindableProperty.Create(nameof(SpaceBetweenButtonTextAndIcon), typeof(int), typeof(DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
104         {
105             var instance = (DropDown)bindable;
106             if (newValue != null)
107             {
108                 instance.spaceBetweenButtonTextAndIcon = (int)newValue;
109             }
110         },
111         defaultValueCreator: (bindable) =>
112         {
113             var instance = (DropDown)bindable;
114             return instance.spaceBetweenButtonTextAndIcon;
115         });
116
117         #region DropDown
118         private Button button = null;
119         private TextLabel headerText = null;
120         private TextLabel buttonText = null;
121         private ImageView listBackgroundImage = null;
122         // Component that scrolls the child added to it.
123         private ScrollableBase scrollableBase = null;
124
125         // The LinearLayout container to house the items in the drop down list.
126         private View dropDownMenuFullList = null;
127         private DropDownListBridge adapter = new DropDownListBridge();
128         private DropDownItemView selectedItemView = null;
129         private TapGestureDetector tapGestureDetector = null;
130
131         private Extents listMargin = new Extents(0, 0, 0, 0);
132         private Extents listPadding = new Extents(0, 0, 0, 0);
133         private ListOrientation listRelativeOrientation = ListOrientation.Left;
134         private int selectedItemIndex = -1;
135         private int spaceBetweenButtonTextAndIcon = 0;
136         private bool itemPressed = false;
137
138         static DropDown() { }
139
140         /// <summary>
141         /// Creates a new instance of a DropDown.
142         /// </summary>
143         /// <since_tizen> 6 </since_tizen>
144         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
145         [EditorBrowsable(EditorBrowsableState.Never)]
146         public DropDown() : base() { }
147
148         /// <summary>
149         /// Creates a new instance of a DropDown with style.
150         /// </summary>
151         /// <param name="style">Create DropDown by special style defined in UX.</param>
152         /// <since_tizen> 6 </since_tizen>
153         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
154         [EditorBrowsable(EditorBrowsableState.Never)]
155         public DropDown(string style) : base(style) { }
156
157         /// <summary>
158         /// Creates a new instance of a DropDown with style.
159         /// </summary>
160         /// <param name="dropDownStyle">Create DropDown by style customized by user.</param>
161         /// <since_tizen> 6 </since_tizen>
162         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
163         [EditorBrowsable(EditorBrowsableState.Never)]
164         public DropDown(DropDownStyle dropDownStyle) : base(dropDownStyle)
165         {
166         }
167
168         /// <summary>
169         /// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
170         /// </summary>
171         /// <since_tizen> 6 </since_tizen>
172         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
173         [EditorBrowsable(EditorBrowsableState.Never)]
174         public delegate void ClickEventHandler<ClickEventArgs>(object sender, ClickEventArgs e);
175
176         /// <summary>
177         /// An event for the item clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
178         /// </summary>
179         /// <since_tizen> 6 </since_tizen>
180         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
181         [EditorBrowsable(EditorBrowsableState.Never)]
182         public event ClickEventHandler<ItemClickEventArgs> ItemClickEvent;
183
184         /// <summary>
185         /// List position in relation to the main button.
186         /// </summary>
187         /// <since_tizen> 6 </since_tizen>
188         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
189         [EditorBrowsable(EditorBrowsableState.Never)]
190         public enum ListOrientation
191         {
192             /// <summary>
193             /// Left.
194             /// </summary>
195             /// <since_tizen> 6 </since_tizen>
196             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
197             [EditorBrowsable(EditorBrowsableState.Never)]
198             Left,
199             /// <summary>
200             /// Right.
201             /// </summary>
202             /// <since_tizen> 6 </since_tizen>
203             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
204             [EditorBrowsable(EditorBrowsableState.Never)]
205             Right,
206         }
207
208         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
209         [EditorBrowsable(EditorBrowsableState.Never)]
210         public new DropDownStyle Style => ViewStyle as DropDownStyle;
211
212         /// <summary>
213         /// Space between button text and button icon in DropDown.
214         /// </summary>
215         /// <since_tizen> 6 </since_tizen>
216         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
217         public int SpaceBetweenButtonTextAndIcon
218         {
219             get => (int)GetValue(SpaceBetweenButtonTextAndIconProperty);
220             set => SetValue(SpaceBetweenButtonTextAndIconProperty, value);
221         }
222
223         /// <summary>
224         /// List relative orientation in DropDown.
225         /// </summary>
226         /// <since_tizen> 6 </since_tizen>
227         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
228         public ListOrientation ListRelativeOrientation
229         {
230             get => (ListOrientation)GetValue(ListRelativeOrientationProperty);
231             set => SetValue(ListRelativeOrientationProperty, value);
232         }
233
234         /// <summary>
235         /// Space in list.
236         /// </summary>
237         /// <since_tizen> 6 </since_tizen>
238         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
239         public Extents ListMargin
240         {
241             get
242             {
243                 Extents tmp = (Extents)GetValue(ListMarginProperty);
244                 return new Extents((ushort start, ushort end, ushort top, ushort bottom) => { ListMargin = new Extents(start, end, top, bottom); }, tmp.Start, tmp.End, tmp.Top, tmp.Bottom);
245             }
246             set => SetValue(ListMarginProperty, value);
247         }
248
249         /// <summary>
250         /// Selected item index in list.
251         /// </summary>
252         /// <since_tizen> 6 </since_tizen>
253         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
254         public int SelectedItemIndex
255         {
256             get => (int)GetValue(SelectedItemIndexProperty);
257             set => SetValue(SelectedItemIndexProperty, value);
258         }
259
260         /// <summary>
261         /// List padding in DropDown.
262         /// </summary>
263         /// <since_tizen> 6 </since_tizen>
264         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
265         public Extents ListPadding
266         {
267             get
268             {
269                 Extents tmp = (Extents)GetValue(ListPaddingProperty);
270                 return new Extents((ushort start, ushort end, ushort top, ushort bottom) => { ListPadding = new Extents(start, end, top, bottom); }, tmp.Start, tmp.End, tmp.Top, tmp.Bottom);
271             }
272             set => SetValue(ListPaddingProperty, value);
273         }
274
275         /// <summary>
276         /// Add list item by item data. The added item will be added to end of all items automatically.
277         /// </summary>
278         /// <param name="itemData">Item data which will apply to tab item view.</param>
279         /// <since_tizen> 6 </since_tizen>
280         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
281         [EditorBrowsable(EditorBrowsableState.Never)]
282         public void AddItem(DropDownDataItem itemData)
283         {
284            // Add item to adaptor, will be added to list via AddItemAt during OnUpdate()
285            int insertionPosition = adapter.GetItemCount();
286            adapter.InsertData(insertionPosition, itemData);
287         }
288
289         /// <summary>
290         /// Delete list item by index.
291         /// </summary>
292         /// <param name="index">Position index where will be deleted.</param>
293         /// <since_tizen> 6 </since_tizen>
294         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
295         [EditorBrowsable(EditorBrowsableState.Never)]
296         public void DeleteItem(int index)
297         {
298             if (index < 0 || index >= adapter?.GetItemCount()) return;
299             if (null == dropDownMenuFullList) return;
300
301             if (selectedItemIndex == index)
302             {
303                 selectedItemIndex = -1;
304             }
305             else if(selectedItemIndex > index)
306             {
307                 selectedItemIndex--;
308             }
309
310             adapter?.RemoveData(index);
311
312             if(index < dropDownMenuFullList.ChildCount)
313             {
314                 View childToRemove = dropDownMenuFullList.GetChildAt((uint)index);
315                 if (childToRemove)
316                 {
317                     childToRemove.TouchEvent -= ListItemTouchEvent;
318                     dropDownMenuFullList.Remove(childToRemove);
319                     dropDownMenuFullList?.Layout?.RequestLayout();
320                 }
321             }
322         }
323
324         /// <summary>
325         /// Insert list item by item data. The inserted item will be added to the special position by index automatically.
326         /// </summary>
327         /// <param name="item">Item data which will apply to tab item view.</param>
328         /// <param name="index">Position index where will be inserted.</param>
329         /// <since_tizen> 6 </since_tizen>
330         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
331         [EditorBrowsable(EditorBrowsableState.Never)]
332         public void InsertItem(DropDownDataItem item, int index)
333         {
334             if (index < 0 || index >= adapter.GetItemCount())
335             {
336                 return;
337             }
338
339             if (selectedItemIndex >= index)
340             {
341                 selectedItemIndex++;
342             }
343
344             adapter.InsertData(index, item);
345         }
346
347         /// <summary>
348         /// Add scroll bar to list.
349         /// </summary>
350         /// <param name="scrollBar">Scroll bar defined by user which will be added to list.</param>
351         /// <since_tizen> 6 </since_tizen>
352         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
353         [EditorBrowsable(EditorBrowsableState.Never)]
354         public void AttachScrollBar(ScrollBar scrollBar)
355         {
356             if (scrollableBase == null)
357             {
358                 return;
359             }
360             Tizen.Log.Error("DropDown","Feature unsupported");
361         }
362
363         /// <summary>
364         /// Detach scroll bar to list.
365         /// </summary>
366         /// <since_tizen> 6 </since_tizen>
367         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
368         [EditorBrowsable(EditorBrowsableState.Never)]
369         public void DetachScrollBar()
370         {
371             if (scrollableBase == null)
372             {
373                 return;
374             }
375             Tizen.Log.Error("DropDown","Feature unsupported");
376         }
377
378         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
379         [EditorBrowsable(EditorBrowsableState.Never)]
380         public override void ApplyStyle(ViewStyle viewStyle)
381         {
382             base.ApplyStyle(viewStyle);
383
384             DropDownStyle dropDownStyle = viewStyle as DropDownStyle;
385             if (null != dropDownStyle)
386             {
387                 CreateHeaderText();
388                 CreateButtonText();
389                 CreateButton();
390
391                 CreateListBackgroundImage();
392                 if (null == scrollableBase) // scrollableBase used to test of ListContainer Setup invoked already
393                 {
394                     SetUpListContainer();
395                 }
396                 button.ApplyStyle(dropDownStyle.Button);
397                 headerText.ApplyStyle(dropDownStyle.HeaderText);
398                 listBackgroundImage.ApplyStyle(dropDownStyle.ListBackgroundImage);
399                 UpdateDropDown();
400             }
401         }
402
403         /// <summary>
404         /// Update DropDown by style.
405         /// </summary>
406         /// <since_tizen> 6 </since_tizen>
407         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
408         [EditorBrowsable(EditorBrowsableState.Never)]
409         protected void UpdateDropDown()
410         {
411             if (null == scrollableBase || null == listBackgroundImage || null == dropDownMenuFullList) return;
412             if (null == Style.ListBackgroundImage.Size) return;
413             // Resize and position scrolling list within the drop down list container.  Can be used to position list in relation to the background image.
414             scrollableBase.Size = Style.ListBackgroundImage.Size - new Size((listPadding.Start + listPadding.End), (listPadding.Top + listPadding.Bottom), 0);
415             scrollableBase.Position2D = new Position2D(listPadding.Start, listPadding.Top);
416
417             int listBackgroundImageX = 0;
418             int listBackgroundImageY = 0;
419             if (listRelativeOrientation == ListOrientation.Left)
420             {
421                 listBackgroundImageX = (int)listMargin.Start;
422                 listBackgroundImageY = (int)listMargin.Top;
423             }
424             else if (listRelativeOrientation == ListOrientation.Right)
425             {
426                 listBackgroundImageX = -(int)listMargin.End;
427                 listBackgroundImageY = (int)listMargin.Top;
428             }
429             listBackgroundImage.Position2D = new Position2D(listBackgroundImageX, listBackgroundImageY);
430             dropDownMenuFullList?.Layout?.RequestLayout();
431         }
432
433         /// <summary>
434         /// update.
435         /// </summary>
436         protected override void OnUpdate()
437         {
438             float buttonTextWidth = 0;
439             if (null != buttonText)
440             {
441                 buttonText.Text = Style.Button.Text.Text.All;
442                 buttonText.PointSize = Style.Button.Text.PointSize?.GetValue(ControlState) ?? StyleManager.PointSizeNormal;
443                 buttonTextWidth = buttonText.NaturalSize.Width;
444             }
445             float fitWidth = (Style.Button.Icon.Size?.Width ?? 48) + Style.SpaceBetweenButtonTextAndIcon + buttonTextWidth;
446             fitWidth += (button.IconPadding.Start + button.IconPadding.End);
447             button.Size.Width = Math.Max(button.Size.Width, fitWidth);
448             RelayoutRequest();
449
450             int numberOfItemsToAdd = adapter.GetItemCount();
451
452             if (adapter.AdapterPurge == true)
453             {
454                 adapter.AdapterPurge = false;
455                 for (int i = 0; i < numberOfItemsToAdd; i++)
456                 {
457                     AddItemAt(adapter.GetData(i), i);
458                 }
459             }
460             // Set selection icon on View
461             if (selectedItemIndex > 0)
462             {
463                 SetListItemToSelected((uint)selectedItemIndex, selectedItemView);
464             }
465         }
466
467         /// <summary>
468         /// Dispose DropDown and all children on it.
469         /// </summary>
470         /// <param name="type">Dispose type.</param>
471         /// <since_tizen> 6 </since_tizen>
472         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
473         [EditorBrowsable(EditorBrowsableState.Never)]
474         protected override void Dispose(DisposeTypes type)
475         {
476             if (disposed)
477             {
478                 return;
479             }
480
481             if (type == DisposeTypes.Explicit)
482             {
483                 Utility.Dispose(headerText);
484                 Utility.Dispose(buttonText);
485                 Utility.Dispose(button);
486                 Utility.Dispose(scrollableBase);
487                 Utility.Dispose(dropDownMenuFullList);
488                 Utility.Dispose(listBackgroundImage);
489             }
490
491             base.Dispose(type);
492         }
493
494         /// <summary>
495         /// Get DropDown style.
496         /// </summary>
497         /// <returns>The default dropdown style.</returns>
498         /// <since_tizen> 6 </since_tizen>
499         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
500         [EditorBrowsable(EditorBrowsableState.Never)]
501         protected override ViewStyle GetViewStyle()
502         {
503             return new DropDownStyle();
504         }
505
506         private void AddItemAt(DropDownDataItem itemData,int index)
507         {
508             ViewHolder viewHolder = adapter.OnCreateViewHolder();
509             if (!viewHolder.IsBound)
510             {
511                 adapter.BindViewHolder(viewHolder, index);
512                 viewHolder.IsBound = true;
513             }
514
515             if (tapGestureDetector == null)
516             {
517                 tapGestureDetector = new TapGestureDetector();
518             }
519             View view = viewHolder.ItemView;
520             view.ApplyStyle(itemData.itemDataStyle);
521             view.TouchEvent += ListItemTouchEvent;
522             dropDownMenuFullList.Add(view);
523         }
524
525         private void OnClickEvent(object sender, ItemClickEventArgs e)
526         {
527             ItemClickEvent?.Invoke(sender, e);
528         }
529
530         private void CreateHeaderText()
531         {
532             if (null == headerText)
533             {
534                 headerText = new TextLabel()
535                 {
536                     WidthResizePolicy = ResizePolicyType.UseNaturalSize,
537                     HeightResizePolicy = ResizePolicyType.UseNaturalSize,
538                     HorizontalAlignment = HorizontalAlignment.Center,
539                     VerticalAlignment = VerticalAlignment.Center,
540                     ParentOrigin = NUI.ParentOrigin.Center,
541                     PivotPoint = NUI.ParentOrigin.Center,
542                     PositionUsesPivotPoint = true,
543                 };
544                 headerText.Name = "DropDownHeaderText";
545                 Add(headerText);
546             }
547         }
548
549         private void CreateButtonText()
550         {
551             if (null == buttonText)
552             {
553                 buttonText = new TextLabel();
554             }
555         }
556
557         private void CreateButton()
558         {
559             if (null == button)
560             {
561                 button = new Button()
562                 {
563                     ParentOrigin = NUI.ParentOrigin.CenterLeft,
564                     PivotPoint = NUI.PivotPoint.CenterLeft,
565                     PositionUsesPivotPoint = true,
566                     HeightResizePolicy = ResizePolicyType.FitToChildren,
567                     IconRelativeOrientation = Button.IconOrientation.Right,
568                 };
569                 button.Name = "DropDownButton";
570                 button.ClickEvent += ButtonClickEvent;
571                 Add(button);
572             }
573         }
574
575         private void CreateListBackgroundImage()
576         {
577             if (null == listBackgroundImage)
578             {
579                 listBackgroundImage = new ImageView
580                 {
581                     Name = "ListBackgroundImage",
582                     PositionUsesPivotPoint = true,
583                     ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
584                     PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
585                     WidthResizePolicy = ResizePolicyType.FitToChildren,
586                     HeightResizePolicy = ResizePolicyType.FitToChildren,
587                 };
588                 Add(listBackgroundImage);
589             }
590         }
591
592         private void SetUpListContainer()
593         {
594             LinearLayout linear = new LinearLayout()
595             {
596                 LinearOrientation = LinearLayout.Orientation.Vertical,
597             };
598
599             dropDownMenuFullList = new View()
600             {
601                 Layout = linear,
602                 Name = "DropDownMenuList",
603                 WidthSpecification = LayoutParamPolicies.MatchParent,
604                 HeightSpecification = LayoutParamPolicies.WrapContent,
605                 Focusable = true,
606             };
607
608             scrollableBase = new ScrollableBase()
609             {
610                 Name = "Scrollable",
611             };
612             scrollableBase.Add(dropDownMenuFullList);
613
614             listBackgroundImage.Add(scrollableBase);
615             listBackgroundImage.Hide();
616         }
617
618         private View GetViewFromIndex(uint index)
619         {
620             if ((index < dropDownMenuFullList.ChildCount) && (index >=0) )
621             {
622                 return dropDownMenuFullList.GetChildAt(index);
623             }
624             else
625             {
626                 return null;
627             }
628         }
629
630         private void SetListItemToSelected(DropDownItemView view)
631         {
632             if (dropDownMenuFullList == null || view == null || view == selectedItemView)
633             {
634                 return;
635             }
636
637             uint newSelectedIndex = 0;
638             for (; newSelectedIndex < dropDownMenuFullList.ChildCount; newSelectedIndex++)
639             {
640                 var itemView = dropDownMenuFullList.GetChildAt(newSelectedIndex) as DropDownItemView;
641                 if (itemView == view)
642                 {
643                     SetListItemToSelected(newSelectedIndex, view);
644                     return;
645                 }
646             }
647         }
648
649         private void SetListItemToSelected(uint index)
650         {
651             if (dropDownMenuFullList == null || index == selectedItemIndex)
652             {
653                 return;
654             }
655
656             SetListItemToSelected(index, GetViewFromIndex(index) as DropDownItemView);
657         }
658
659         private void SetListItemToSelected(uint index, DropDownItemView view)
660         {
661             if (adapter == null)
662             {
663                 return;
664             }
665
666             if (selectedItemView != null)
667             {
668                 selectedItemView.IsSelected = false;
669                 selectedItemView.ControlState = ControlStates.Normal;
670                 adapter.GetData(selectedItemIndex).IsSelected = false;
671             }
672
673             if (view == null || index >= dropDownMenuFullList.ChildCount)
674             {
675                 selectedItemIndex = -1;
676                 selectedItemView = null;
677                 return;
678             }
679
680             selectedItemIndex = (int)index;
681             selectedItemView = view;
682             selectedItemView.ControlState = ControlStates.Selected;
683             selectedItemView.IsSelected = true;
684             adapter.GetData(selectedItemIndex).IsSelected = true;
685             dropDownMenuFullList.Layout?.RequestLayout();
686         }
687
688         private bool ListItemTouchEvent(object sender, TouchEventArgs e)
689         {
690             PointStateType state = e.Touch.GetState(0);
691             DropDownItemView touchedView = sender as DropDownItemView;;
692             switch (state)
693             {
694                 case PointStateType.Down:
695                     if (touchedView != null)
696                     {
697                         touchedView.ControlState = ControlStates.Pressed;
698                     }
699                     itemPressed = true;  // if matched with a Up then a click event.
700                     break;
701                 case PointStateType.Motion:
702                     if (touchedView != null)
703                     {
704                         touchedView.ControlState = ControlStates.Normal;
705                     }
706                     itemPressed = false;
707                     break;
708                 case PointStateType.Up:
709                     if (touchedView != null)
710                     {
711                         if (itemPressed)  // if Down was previously sent without motion (Scrolling) in-between then a clicked event occurred.
712                         {
713                             // List item clicked
714                             Console.WriteLine("Tapped{0}", touchedView.Name);
715                             SetListItemToSelected(touchedView);
716                             button.Text = touchedView.Text;
717                             button.Show();
718                             listBackgroundImage.Hide();
719                         }
720                     }
721                     break;
722                 default:
723                     break;
724             }
725             return true;
726         }
727
728         private void ButtonClickEvent(object sender, Button.ClickEventArgs e)
729         {
730             button.Hide();
731             listBackgroundImage.Show();
732             dropDownMenuFullList?.Layout?.RequestLayout();
733             listBackgroundImage.RaiseToTop();
734         }
735
736         #endregion
737
738         #region ItemClickEventArgs
739         /// <summary>
740         /// ItemClickEventArgs is a class to record item click event arguments which will sent to user.
741         /// </summary>
742         /// <since_tizen> 6 </since_tizen>
743         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
744         [EditorBrowsable(EditorBrowsableState.Never)]
745         public class ItemClickEventArgs : EventArgs
746         {
747             /// <summary> Clicked item index of DropDown's list </summary>
748             /// <since_tizen> 6 </since_tizen>
749             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
750             [EditorBrowsable(EditorBrowsableState.Never)]
751             public int Index;
752             /// <summary> Clicked item text string of DropDown's list </summary>
753             /// <since_tizen> 6 </since_tizen>
754             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
755             [EditorBrowsable(EditorBrowsableState.Never)]
756             public string Text;
757         }
758         #endregion
759
760         #region DropDownDataItem
761         /// <summary>
762         /// DropDownDataItem is a class to record all data which will be applied to DropDown item.
763         /// </summary>
764         /// <since_tizen> 6 </since_tizen>
765         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
766         //[EditorBrowsable(EditorBrowsableState.Never)]
767         public class DropDownDataItem
768         {
769             internal DropDownItemStyle itemDataStyle = new DropDownItemStyle();
770
771             /// <summary>
772             /// Creates a new instance of a DropDownItemData.
773             /// </summary>
774             /// <since_tizen> 6 </since_tizen>
775             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
776             [EditorBrowsable(EditorBrowsableState.Never)]
777             public DropDownDataItem()
778             {
779                 itemDataStyle = (DropDownItemStyle)StyleManager.Instance.GetComponentStyle(this.GetType());
780                 Initialize();
781             }
782
783             /// <summary>
784             /// Creates a new instance of a DropDownItemData with style.
785             /// </summary>
786             /// <param name="style">Create DropDownItemData by special style defined in UX.</param>
787             /// <since_tizen> 6 </since_tizen>
788             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
789             [EditorBrowsable(EditorBrowsableState.Never)]
790             public DropDownDataItem(string style)
791             {
792                 if(style != null)
793                 {
794                     ViewStyle viewStyle = StyleManager.Instance.GetViewStyle(style);
795                     if(viewStyle == null)
796                     {
797                         throw new InvalidOperationException($"There is no style {style}");
798                     }
799                     itemDataStyle = viewStyle as DropDownItemStyle;
800                 }
801                 Initialize();
802             }
803
804             /// <summary>
805             /// Creates a new instance of a DropDownItemData with style.
806             /// </summary>
807             /// <param name="style">Create DropDownItemData by style customized by user.</param>
808             /// <since_tizen> 6 </since_tizen>
809             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
810             [EditorBrowsable(EditorBrowsableState.Never)]
811             public DropDownDataItem(DropDownItemStyle style)
812             {
813                 itemDataStyle.CopyFrom(style);
814                 Initialize();
815             }
816
817             /// <summary>
818             /// DropDown item size.
819             /// </summary>
820             /// <since_tizen> 6 </since_tizen>
821             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
822             [EditorBrowsable(EditorBrowsableState.Never)]
823             public Size Size
824             {
825                 get
826                 {
827                     return itemDataStyle.Size;
828                 }
829                 set
830                 {
831                     itemDataStyle.Size = value;
832                 }
833             }
834
835             /// <summary>
836             /// DropDown item background color selector.
837             /// </summary>
838             /// <since_tizen> 6 </since_tizen>
839             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
840             [EditorBrowsable(EditorBrowsableState.Never)]
841             public Selector<Color> BackgroundColor
842             {
843                 get
844                 {
845                     return itemDataStyle.BackgroundColor;
846                 }
847                 set
848                 {
849                     if (null == itemDataStyle?.BackgroundColor)
850                     {
851                         itemDataStyle.BackgroundColor = new Selector<Color>();
852                     }
853
854                     itemDataStyle.BackgroundColor.Clone(value);
855                 }
856             }
857
858             /// <summary>
859             /// DropDown item text string.
860             /// </summary>
861             /// <since_tizen> 6 </since_tizen>
862             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
863             [EditorBrowsable(EditorBrowsableState.Never)]
864             public string Text
865             {
866                 get
867                 {
868                     return itemDataStyle.Text?.Text?.All;
869                 }
870                 set
871                 {
872                     if (null == itemDataStyle.Text.Text)
873                     {
874                         itemDataStyle.Text.Text = new Selector<string> { All = value };
875                     }
876                     else
877                     {
878                         itemDataStyle.Text.Text = value;
879                     }
880                 }
881             }
882
883             /// <summary>
884             /// DropDown item text's point size.
885             /// </summary>
886             /// <since_tizen> 6 </since_tizen>
887             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
888             [EditorBrowsable(EditorBrowsableState.Never)]
889             public float PointSize
890             {
891                 get
892                 {
893                     return itemDataStyle.Text?.PointSize?.All ?? 0;
894                 }
895                 set
896                 {
897                     if (null == itemDataStyle.Text.PointSize)
898                     {
899                         itemDataStyle.Text.PointSize = new Selector<float?> { All = value };
900                     }
901                     else
902                     {
903                         itemDataStyle.Text.PointSize = value;
904                     }
905                 }
906             }
907
908             /// <summary>
909             /// DropDown item text's font family.
910             /// </summary>
911             /// <since_tizen> 6 </since_tizen>
912             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
913             [EditorBrowsable(EditorBrowsableState.Never)]
914             public string FontFamily
915             {
916                 get
917                 {
918                     return itemDataStyle.Text.FontFamily?.All;
919                 }
920                 set
921                 {
922                     if (null == itemDataStyle.Text.FontFamily)
923                     {
924                         itemDataStyle.Text.FontFamily = new Selector<string> { All = value };
925                     }
926                     else
927                     {
928                         itemDataStyle.Text.FontFamily = value;
929                     }
930                 }
931             }
932
933             /// <summary>
934             /// DropDown item text's position.
935             /// </summary>
936             /// <since_tizen> 6 </since_tizen>
937             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
938             [EditorBrowsable(EditorBrowsableState.Never)]
939             public Position TextPosition
940             {
941                 get
942                 {
943                     return itemDataStyle.Text?.Position;
944                 }
945                 set
946                 {
947                     itemDataStyle.Text.Position = value;
948                 }
949             }
950
951             /// <summary>
952             /// DropDown item's icon's resource url.
953             /// </summary>
954             /// <since_tizen> 6 </since_tizen>
955             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
956             [EditorBrowsable(EditorBrowsableState.Never)]
957             public string IconResourceUrl
958             {
959                 get
960                 {
961                     return itemDataStyle.Icon?.ResourceUrl?.All;
962                 }
963                 set
964                 {
965                     if (null == itemDataStyle.Icon.ResourceUrl)
966                     {
967                         itemDataStyle.Icon.ResourceUrl = new Selector<string> { All = value };
968                     }
969                     else
970                     {
971                         itemDataStyle.Icon.ResourceUrl = value;
972                     }
973                 }
974             }
975
976             /// <summary>
977             /// DropDown item's icon's size.
978             /// </summary>
979             /// <since_tizen> 6 </since_tizen>
980             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
981             [EditorBrowsable(EditorBrowsableState.Never)]
982             public Size IconSize
983             {
984                 get
985                 {
986                     return itemDataStyle.Icon?.Size;
987                 }
988                 set
989                 {
990                     itemDataStyle.Icon.Size = value;
991                 }
992             }
993
994             /// <summary>
995             /// DropDown item's icon's position.
996             /// </summary>
997             /// <since_tizen> 6 </since_tizen>
998             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
999             [EditorBrowsable(EditorBrowsableState.Never)]
1000             public Position IconPosition
1001             {
1002                 get
1003                 {
1004                     return itemDataStyle.Icon.Position;
1005                 }
1006                 set
1007                 {
1008                     itemDataStyle.Icon.Position = value;
1009                 }
1010             }
1011
1012             /// <summary>
1013             /// DropDown item's check image's resource url.
1014             /// </summary>
1015             /// <since_tizen> 6 </since_tizen>
1016             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1017             [EditorBrowsable(EditorBrowsableState.Never)]
1018             public string CheckImageResourceUrl
1019             {
1020                 get
1021                 {
1022                     return itemDataStyle.CheckImage?.ResourceUrl?.All;
1023                 }
1024                 set
1025                 {
1026                     if (null == itemDataStyle.CheckImage.ResourceUrl)
1027                     {
1028                         itemDataStyle.CheckImage.ResourceUrl = new Selector<string> { All = value };
1029                     }
1030                     else
1031                     {
1032                         itemDataStyle.CheckImage.ResourceUrl = value;
1033                     }
1034                 }
1035             }
1036
1037             /// <summary>
1038             /// DropDown item's check image's size.
1039             /// </summary>
1040             /// <since_tizen> 6 </since_tizen>
1041             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1042             [EditorBrowsable(EditorBrowsableState.Never)]
1043             public Size CheckImageSize
1044             {
1045                 get
1046                 {
1047                     return itemDataStyle.CheckImage?.Size;
1048                 }
1049                 set
1050                 {
1051                     itemDataStyle.CheckImage.Size = value;
1052                 }
1053             }
1054
1055             /// <summary>
1056             /// DropDown item's check image's right space.
1057             /// </summary>
1058             /// <since_tizen> 6 </since_tizen>
1059             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1060             [EditorBrowsable(EditorBrowsableState.Never)]
1061             public int CheckImageGapToBoundary
1062             {
1063                 get
1064                 {
1065                     return itemDataStyle.CheckImageGapToBoundary;
1066                 }
1067                 set
1068                 {
1069                     itemDataStyle.CheckImageGapToBoundary = value;
1070                 }
1071             }
1072
1073             /// <summary>
1074             /// Flag to decide DropDown item is selected or not.
1075             /// </summary>
1076             /// <since_tizen> 6 </since_tizen>
1077             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1078             [EditorBrowsable(EditorBrowsableState.Never)]
1079             public bool IsSelected
1080             {
1081                 get
1082                 {
1083                     return itemDataStyle.IsSelected;
1084                 }
1085                 set
1086                 {
1087                     itemDataStyle.IsSelected = value;
1088                 }
1089             }
1090
1091             private void Initialize()
1092             {
1093                 if (itemDataStyle == null)
1094                 {
1095                     throw new Exception("DropDownDataItem style parse error.");
1096                 }
1097             }
1098         }
1099         #endregion
1100
1101         #region DropDownItemView
1102         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1103         [EditorBrowsable(EditorBrowsableState.Never)]
1104         internal class DropDownItemView : Control
1105         {
1106             private TextLabel mText = null;
1107             private ImageView mIcon = null;
1108             private ImageView mCheck = null;
1109
1110             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1111             [EditorBrowsable(EditorBrowsableState.Never)]
1112             public DropDownItemView() : base() { }
1113
1114             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1115             [EditorBrowsable(EditorBrowsableState.Never)]
1116             public Selector<Color> BackgroundColorSelector { get; set; }
1117
1118             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1119             [EditorBrowsable(EditorBrowsableState.Never)]
1120             public string Text
1121             {
1122                 get
1123                 {
1124                     return (null == mText) ? null : mText.Text;
1125                 }
1126                 set
1127                 {
1128                     CreateText();
1129                     mText.Text = value;
1130                 }
1131             }
1132
1133             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1134             [EditorBrowsable(EditorBrowsableState.Never)]
1135             public string FontFamily
1136             {
1137                 get
1138                 {
1139                     return (null == mText) ? null : mText.FontFamily;
1140                 }
1141                 set
1142                 {
1143                     CreateText();
1144                     mText.FontFamily = value;
1145                 }
1146             }
1147
1148             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1149             [EditorBrowsable(EditorBrowsableState.Never)]
1150             public float? PointSize
1151             {
1152                 get
1153                 {
1154                     return (null == mText) ? 0 : mText.PointSize;
1155                 }
1156                 set
1157                 {
1158                     CreateText();
1159                     mText.PointSize = (float)value;
1160                 }
1161             }
1162
1163             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1164             [EditorBrowsable(EditorBrowsableState.Never)]
1165             public Color TextColor
1166             {
1167                 get
1168                 {
1169                     return (null == mText) ? null : mText.TextColor;
1170                 }
1171                 set
1172                 {
1173                     CreateText();
1174                     mText.TextColor = value;
1175                 }
1176             }
1177
1178             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1179             [EditorBrowsable(EditorBrowsableState.Never)]
1180             public Position TextPosition
1181             {
1182                 get
1183                 {
1184                     return (null == mText) ? null : mText.Position;
1185                 }
1186                 set
1187                 {
1188                     CreateText();
1189                     mText.Position = value;
1190                 }
1191             }
1192
1193             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1194             [EditorBrowsable(EditorBrowsableState.Never)]
1195             public string IconResourceUrl
1196             {
1197                 get
1198                 {
1199                     return (null == mIcon) ? null : mIcon.ResourceUrl;
1200                 }
1201                 set
1202                 {
1203                     CreateIcon();
1204                     mIcon.ResourceUrl = value;
1205                 }
1206             }
1207
1208             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1209             [EditorBrowsable(EditorBrowsableState.Never)]
1210             public Size IconSize
1211             {
1212                 get
1213                 {
1214                     return (null == mIcon) ? null : mIcon.Size;
1215                 }
1216                 set
1217                 {
1218                     CreateIcon();
1219                     mIcon.Size = value;
1220                 }
1221             }
1222
1223             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1224             [EditorBrowsable(EditorBrowsableState.Never)]
1225             public Position IconPosition
1226             {
1227                 get
1228                 {
1229                     return (null == mIcon) ? null : mIcon.Position;
1230                 }
1231                 set
1232                 {
1233                     CreateIcon();
1234                     mIcon.Position = value;
1235                 }
1236             }
1237
1238             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1239             [EditorBrowsable(EditorBrowsableState.Never)]
1240             public string CheckResourceUrl
1241             {
1242                 get
1243                 {
1244                     return (null == mCheck) ? null : mCheck.ResourceUrl;
1245                 }
1246                 set
1247                 {
1248                     CreateCheckImage();
1249                     mCheck.ResourceUrl = value;
1250                 }
1251             }
1252
1253             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1254             [EditorBrowsable(EditorBrowsableState.Never)]
1255             public Position CheckPosition
1256             {
1257                 get
1258                 {
1259                     return (null == mCheck) ? null : mCheck.Position;
1260                 }
1261                 set
1262                 {
1263                     CreateCheckImage();
1264                     mCheck.Position = value;
1265                 }
1266             }
1267
1268             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1269             [EditorBrowsable(EditorBrowsableState.Never)]
1270             public Size CheckImageSize
1271             {
1272                 get
1273                 {
1274                     return (null == mCheck) ? null : mCheck.Size;
1275                 }
1276                 set
1277                 {
1278                     CreateCheckImage();
1279                     mCheck.Size = value;
1280                 }
1281             }
1282
1283             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1284             [EditorBrowsable(EditorBrowsableState.Never)]
1285             public bool IsSelected
1286             {
1287                 get
1288                 {
1289                     return (null == mCheck) ? false : mCheck.Visibility;
1290                 }
1291                 set
1292                 {
1293                     CreateCheckImage();
1294                     if(value)
1295                     {
1296                         mCheck.Show();
1297                     }
1298                     else
1299                     {
1300                         mCheck.Hide();
1301                     }
1302                 }
1303             }
1304
1305             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1306             [EditorBrowsable(EditorBrowsableState.Never)]
1307             protected override void Dispose(DisposeTypes type)
1308             {
1309                 if (disposed)
1310                 {
1311                     return;
1312                 }
1313
1314                 if (type == DisposeTypes.Explicit)
1315                 {
1316                     if (mText != null)
1317                     {
1318                         Remove(mText);
1319                         mText.Dispose();
1320                         mText = null;
1321                     }
1322
1323                     if (mIcon != null)
1324                     {
1325                         Remove(mIcon);
1326                         mIcon.Dispose();
1327                         mIcon = null;
1328                     }
1329
1330                     if (mCheck != null)
1331                     {
1332                         Remove(mCheck);
1333                         mCheck.Dispose();
1334                         mCheck = null;
1335                     }
1336                 }
1337                 base.Dispose(type);
1338             }
1339
1340             /// <summary>
1341             /// Get DropDownItemView style.
1342             /// </summary>
1343             /// <returns>The empty.</returns>
1344             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1345             [EditorBrowsable(EditorBrowsableState.Never)]
1346             protected override ViewStyle GetViewStyle()
1347             {
1348                 return null;
1349             }
1350
1351             private void CreateIcon()
1352             {
1353                 if(mIcon == null)
1354                 {
1355                     mIcon = new ImageView()
1356                     {
1357                         PositionUsesPivotPoint = true,
1358                         ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1359                         PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1360                     };
1361                     Add(mIcon);
1362                 }
1363             }
1364
1365             private void CreateText()
1366             {
1367                 if (mText == null)
1368                 {
1369                     mText = new TextLabel()
1370                     {
1371                         PositionUsesPivotPoint = true,
1372                         ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1373                         PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1374                         WidthResizePolicy = ResizePolicyType.UseNaturalSize,
1375                         HeightResizePolicy = ResizePolicyType.FillToParent,
1376                         VerticalAlignment = VerticalAlignment.Center,
1377                         HorizontalAlignment = HorizontalAlignment.Begin,
1378                     };
1379                     Add(mText);
1380                 }
1381             }
1382
1383             private void CreateCheckImage()
1384             {
1385                 if (mCheck == null)
1386                 {
1387                     mCheck = new ImageView()
1388                     {
1389                         PositionUsesPivotPoint = true,
1390                         ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1391                         PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1392                         Name = "checkedImage",
1393                     };
1394                     Add(mCheck);
1395                 }
1396                 mCheck.Hide();
1397             }
1398         }
1399         #endregion
1400
1401         #region DropDownListBridge
1402
1403         /// <summary>
1404         /// DropDownListBridge is bridge to connect item data and an item View.
1405         /// </summary>
1406         /// <since_tizen> 6 </since_tizen>
1407         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1408         [EditorBrowsable(EditorBrowsableState.Never)]
1409         public class DropDownListBridge
1410         {
1411             private List<DropDownDataItem> itemDataList = new List<DropDownDataItem>();
1412
1413             internal bool AdapterPurge {get;set;} = false;  // Set to true if adapter content changed since last iteration.
1414
1415             /// <summary>
1416             /// Creates a new instance of a DropDownListBridge.
1417             /// </summary>
1418             /// <since_tizen> 6 </since_tizen>
1419             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1420             [EditorBrowsable(EditorBrowsableState.Never)]
1421             public DropDownListBridge() { }
1422
1423             /// <summary>
1424             /// Insert data. The inserted data will be added to the special position by index automatically.
1425             /// </summary>
1426             /// <param name="position">Position index where will be inserted.</param>
1427             /// <param name="data">Item data which will apply to tab item view.</param>
1428             /// <since_tizen> 6 </since_tizen>
1429             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1430             [EditorBrowsable(EditorBrowsableState.Never)]
1431             public void InsertData(int position, DropDownDataItem data)
1432             {
1433                 if(position == -1)
1434                 {
1435                     position = itemDataList.Count;
1436                 }
1437                 itemDataList.Insert(position, data);
1438                 AdapterPurge = true;
1439             }
1440
1441             /// <summary>
1442             /// Remove data by position.
1443             /// </summary>
1444             /// <param name="position">Position index where will be removed.</param>
1445             /// <since_tizen> 6 </since_tizen>
1446             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1447             [EditorBrowsable(EditorBrowsableState.Never)]
1448             public void RemoveData(int position)
1449             {
1450                 itemDataList.RemoveAt(position);
1451                 AdapterPurge = true;
1452             }
1453
1454             /// <summary>
1455             /// Get data by position.
1456             /// </summary>
1457             /// <param name="position">Position index where will be gotten.</param>
1458             /// <since_tizen> 6 </since_tizen>
1459             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1460             [EditorBrowsable(EditorBrowsableState.Never)]
1461             public DropDownDataItem GetData(int position)
1462             {
1463                 return itemDataList[position];
1464             }
1465
1466             /// <summary>
1467             /// Get view holder by view type.
1468             /// </summary>
1469             /// <since_tizen> 6 </since_tizen>
1470             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1471             [EditorBrowsable(EditorBrowsableState.Never)]
1472             public ViewHolder OnCreateViewHolder()
1473             {
1474                 ViewHolder viewHolder = new ViewHolder(new DropDownItemView());
1475
1476                 return viewHolder;
1477             }
1478
1479             /// <summary>
1480             /// Bind ViewHolder with View.
1481             /// </summary>
1482             /// <param name="holder">View holder.</param>
1483             /// <param name="position">Position index of source data.</param>
1484             /// <since_tizen> 6 </since_tizen>
1485             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1486             [EditorBrowsable(EditorBrowsableState.Never)]
1487             public void BindViewHolder(ViewHolder holder, int position)
1488             {
1489                 if (null == holder) return;
1490                 DropDownDataItem listItemData = itemDataList[position];
1491                 if(listItemData == null)
1492                 {
1493                     return;
1494                 }
1495                 DropDownItemView listItemView = holder.ItemView as DropDownItemView;
1496                 listItemView.Name = "Item" + position;
1497                 if (listItemData.Size != null)
1498                 {
1499                     if (listItemData.Size.Width > 0)
1500                     {
1501                         holder.ItemView.WidthSpecification = (int)listItemData.Size.Width;
1502                     }
1503                     else
1504                     {
1505                         holder.ItemView.WidthSpecification = LayoutParamPolicies.MatchParent;
1506                     }
1507
1508                     if (listItemData.Size.Height > 0)
1509                     {
1510                         holder.ItemView.HeightSpecification = (int)listItemData.Size.Height;
1511                     }
1512                     else
1513                     {
1514                         holder.ItemView.HeightSpecification = LayoutParamPolicies.MatchParent;
1515                     }
1516                 }
1517
1518                 if (listItemView != null)
1519                 {
1520                     listItemView.BackgroundColorSelector = listItemData.BackgroundColor;
1521                     if (listItemData.Text != null)
1522                     {
1523                         listItemView.Text = listItemData.Text;
1524                         listItemView.PointSize = listItemData.PointSize;
1525                         listItemView.FontFamily = listItemData.FontFamily;
1526                         listItemView.TextPosition = listItemData.TextPosition;
1527                     }
1528
1529                     if (listItemData.IconResourceUrl != null)
1530                     {
1531                         listItemView.IconResourceUrl = listItemData.IconResourceUrl;
1532                         listItemView.IconSize = listItemData.IconSize;
1533                         if (listItemView.IconSize != null)
1534                         {
1535                             listItemView.IconPosition = new Position(listItemData.IconPosition.X, (listItemView.Size2D.Height - listItemView.IconSize.Height) / 2);
1536                         }
1537                     }
1538
1539                     if (listItemData.CheckImageResourceUrl != null)
1540                     {
1541                         listItemView.CheckResourceUrl = listItemData.CheckImageResourceUrl;
1542
1543                         if (null != listItemData.CheckImageSize)
1544                         {
1545                             listItemView.CheckImageSize = listItemData.CheckImageSize;
1546                         }
1547
1548                         if (listItemView.CheckImageSize != null)
1549                         {
1550                             listItemView.CheckPosition = new Position(listItemView.Size2D.Width - listItemData.CheckImageGapToBoundary - listItemView.CheckImageSize.Width, (listItemView.Size2D.Height - listItemView.CheckImageSize.Height) / 2);
1551                         }
1552                     }
1553
1554                     listItemView.IsSelected = listItemData.IsSelected;
1555                 }
1556             }
1557
1558             /// <summary>
1559             /// Destroy view holder, it can be override.
1560             /// </summary>
1561             /// <param name="holder">View holder.</param>
1562             /// <since_tizen> 6 </since_tizen>
1563             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1564             [EditorBrowsable(EditorBrowsableState.Never)]
1565             public void OnDestroyViewHolder(ViewHolder holder)
1566             {
1567                 if (null == holder) return;
1568                 if (holder.ItemView != null)
1569                 {
1570                     holder.ItemView.Dispose();
1571                 }
1572             }
1573
1574             /// <summary>
1575             /// Get item count, it can be override.
1576             /// </summary>
1577             /// <since_tizen> 6 </since_tizen>
1578             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1579             [EditorBrowsable(EditorBrowsableState.Never)]
1580             public int GetItemCount()
1581             {
1582                 return itemDataList.Count;
1583             }
1584         }
1585
1586         #endregion
1587
1588         #region ViewHolder
1589
1590         /// <summary>
1591         /// A ViewHolder is a class that holds a View created from DropDownListBridge data.
1592         /// </summary>
1593         /// <since_tizen> 6 </since_tizen>
1594         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1595         [EditorBrowsable(EditorBrowsableState.Never)]
1596         public class ViewHolder
1597         {
1598             /// <summary>
1599             /// ViewHolder constructor.
1600             /// </summary>
1601             /// <param name="itemView">View</param>
1602             /// <since_tizen> 6 </since_tizen>
1603             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1604             [EditorBrowsable(EditorBrowsableState.Never)]
1605             public ViewHolder(View itemView)
1606             {
1607                 if (itemView == null)
1608                 {
1609                     throw new ArgumentNullException("itemView may not be null");
1610                 }
1611                 this.ItemView = itemView;
1612             }
1613
1614             /// <summary>
1615             /// Returns the view.
1616             /// </summary>
1617             /// <since_tizen> 6 </since_tizen>
1618             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1619             [EditorBrowsable(EditorBrowsableState.Never)]
1620             public View ItemView { get; }
1621
1622             internal bool IsBound { get; set; }
1623         }
1624
1625         #endregion
1626     }
1627 }