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