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