CollectionView colView;
string selectedItem;
ItemSelectionMode selMode;
- ObservableCollection<Album> groupSource;
+ ObservableCollection<Album> albumSource;
+ Album insertDeleteGroup = new Album(999, "Insert / Delete Groups", new DateTime(1999, 12, 31));
+ Gallery insertMenu = new Gallery(999, "Insert item to first of 3rd Group");
+ Gallery deleteMenu = new Gallery(999, "Delete first item in 3rd Group");
+ Album moveGroup = new Album(999, "move Groups", new DateTime(1999, 12, 31));
+ Gallery moveMenu = new Gallery(999, "Move last item to first in 3rd group");
public void Activate()
{
Window window = NUIApplication.GetDefaultWindow();
- groupSource = new AlbumViewModel();
+ albumSource = new AlbumViewModel();
+ // Add test menu options.
+ moveGroup.Add(moveMenu);
+ albumSource.Insert(0, moveGroup);
+ insertDeleteGroup.Add(insertMenu);
+ insertDeleteGroup.Add(deleteMenu);
+ albumSource.Insert(0, insertDeleteGroup);
+
selMode = ItemSelectionMode.SingleSelection;
DefaultTitleItem myTitle = new DefaultTitleItem();
//To Bind the Count property changes, need to create custom property for count.
- myTitle.Text = "Linear Sample Group["+ groupSource.Count+"]";
+ myTitle.Text = "Linear Sample Group["+ albumSource.Count+"]";
//Set Width Specification as MatchParent to fit the Item width with parent View.
myTitle.WidthSpecification = LayoutParamPolicies.MatchParent;
colView = new CollectionView()
{
- ItemsSource = groupSource,
+ ItemsSource = albumSource,
ItemsLayouter = new LinearLayouter(),
ItemTemplate = new DataTemplate(() =>
{
- var rand = new Random();
- RecyclerViewItem item = new RecyclerViewItem();
- item.WidthSpecification = LayoutParamPolicies.MatchParent;
- item.HeightSpecification = 100;
- item.BackgroundColor = new Color((float)rand.NextDouble(), (float)rand.NextDouble(), (float)rand.NextDouble(), 1);
- /*
DefaultLinearItem item = new DefaultLinearItem();
//Set Width Specification as MatchParent to fit the Item width with parent View.
item.WidthSpecification = LayoutParamPolicies.MatchParent;
//item.Extra.SetBinding(RadioButton.IsSelectedProperty, "Selected");
item.Extra.WidthSpecification = 80;
item.Extra.HeightSpecification = 80;
- */
+
return item;
}),
GroupHeaderTemplate = new DataTemplate(() =>
{
- var rand = new Random();
- RecyclerViewItem item = new RecyclerViewItem();
- item.WidthSpecification = LayoutParamPolicies.MatchParent;
- item.HeightSpecification = 50;
- item.BackgroundColor = new Color(0, 0, 0, 1);
- /*
DefaultTitleItem group = new DefaultTitleItem();
//Set Width Specification as MatchParent to fit the Item width with parent View.
group.WidthSpecification = LayoutParamPolicies.MatchParent;
group.Label.SetBinding(TextLabel.TextProperty, "Date");
group.Label.HorizontalAlignment = HorizontalAlignment.Begin;
- */
- return item;
+
+ return group;
}),
Header = myTitle,
IsGrouped = true,
foreach (object item in ev.PreviousSelection)
{
if (item == null) break;
- Gallery unselItem = (Gallery)item;
-
- unselItem.Selected = false;
- selectedItem = null;
- //Tizen.Log.Debug("NUI", "LSH :: Unselected: {0}", unselItem.ViewLabel);
+ if (item is Gallery unselItem)
+ {
+ unselItem.Selected = false;
+ selectedItem = null;
+ //Tizen.Log.Debug("NUI", "LSH :: Unselected: {0}", unselItem.ViewLabel);
+ }
+ else if (item is Album selAlbum)
+ {
+ selectedItem = selAlbum.Title;
+ selAlbum.Selected = false;
+ if (selAlbum == insertDeleteGroup)
+ {
+ albumSource.RemoveAt(2);
+ }
+ }
+
}
foreach (object item in ev.CurrentSelection)
{
if (item == null) break;
- Gallery selItem = (Gallery)item;
- selItem.Selected = true;
- selectedItem = selItem.Name;
- //Tizen.Log.Debug("NUI", "LSH :: Selected: {0}", selItem.ViewLabel);
+ if (item is Gallery selItem)
+ {
+ selItem.Selected = true;
+ selectedItem = selItem.Name;
+ //Tizen.Log.Debug("NUI", "LSH :: Selected: {0}", selItem.ViewLabel);
+
+ // Check test menu options.
+ if (selItem == insertMenu)
+ {
+ // Insert new item to index 3.
+ Random rand = new Random();
+ int idx = rand.Next(1000);
+ albumSource[2].Insert(0, new Gallery(idx, "Inserted Item"));
+ }
+ else if (selItem == deleteMenu)
+ {
+ // Remove item in index 3.
+ albumSource[2].RemoveAt(0);
+ }
+ else if (selItem == moveMenu)
+ {
+ // Move last indexed item to index 3.
+ albumSource[2].Move(albumSource[2].Count - 1, 0);
+ }
+ }
+ else if (item is Album selAlbum)
+ {
+ selectedItem = selAlbum.Title;
+ selAlbum.Selected = true;
+ if (selAlbum == insertDeleteGroup)
+ {
+ Random rand = new Random();
+ int groupIdx = rand.Next(1000);
+ Album insertAlbum = new Album(groupIdx, "Inserted group", new DateTime(1999, 12, 31));
+ int idx = rand.Next(1000);
+ insertAlbum.Add(new Gallery(idx, "Inserted Item 1"));
+ idx = rand.Next(1000);
+ insertAlbum.Add(new Gallery(idx, "Inserted Item 2"));
+ idx = rand.Next(1000);
+ insertAlbum.Add(new Gallery(idx, "Inserted Item 3"));
+ albumSource.Insert(2, insertAlbum);
+ }
+ else if (selAlbum == moveGroup)
+ {
+ albumSource.Move(albumSource.Count - 1, 2);
+
+ }
+ }
}
if (colView.Header != null && colView.Header is DefaultTitleItem)
{
DefaultTitleItem title = (DefaultTitleItem)colView.Header;
- title.Text = "Linear Sample Count[" + groupSource + (selectedItem != null ? "] Selected [" + selectedItem + "]" : "]");
+ title.Text = "Linear Sample Count[" + albumSource.Count + (selectedItem != null ? "] Selected [" + selectedItem + "]" : "]");
}
}
+
public void Deactivate()
{
if (colView != null)