2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Collections.ObjectModel;
19 using System.ComponentModel;
21 using Tizen.NUI.Binding;
22 using Tizen.NUI.BaseComponents;
23 using Tizen.NUI.Components;
24 using Tizen.NUI.Components.Extension;
26 namespace NUITizenGallery
28 public partial class CollectionViewTest8 : ContentPage
30 public CollectionViewTest8()
32 InitializeComponent();
33 BindingContext = new TestSourceModel(40);
35 var customStyle = new RecyclerViewItemStyle()
37 BackgroundColor = new Selector<Color>()
41 Selected = Color.Blue,
42 Disabled = Color.Grey,
46 ColView.ItemTemplate = new DataTemplate(() =>
48 var item = new RecyclerViewItem(customStyle)
50 WidthSpecification = 100,
51 HeightSpecification = LayoutParamPolicies.MatchParent,
53 var label = new TextLabel()
55 ParentOrigin = Tizen.NUI.ParentOrigin.Center,
56 PivotPoint = Tizen.NUI.PivotPoint.Center,
57 PositionUsesPivotPoint = true,
60 label.SetBinding(TextLabel.TextProperty, "Index");
67 protected override void Dispose(DisposeTypes type)
74 if (type == DisposeTypes.Explicit)
76 RemoveAllChildren(true);
82 private void RemoveAllChildren(bool dispose = false)
84 RecursiveRemoveChildren(this, dispose);
87 private void RecursiveRemoveChildren(View parent, bool dispose)
94 int maxChild = (int)parent.ChildCount;
95 for (int i = maxChild - 1; i >= 0; --i)
97 View child = parent.GetChildAt((uint)i);
103 RecursiveRemoveChildren(child, dispose);
104 parent.Remove(child);