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