Ejemplo n.º 1
0
 public static void Make(FastListView fastListView)
 {
     ConfigureColumns(fastListView);
     fastListView.ShowGroups                    = false;
     fastListView.ShowItemCountOnGroups         = true;
     fastListView.SortGroupItemsByPrimaryColumn = false;
     fastListView.FullRowSelect                 = true;
 }
Ejemplo n.º 2
0
            public Issue3275TransactionsPage1()
            {
                var grd = new Grid();

                grd.RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });
                grd.RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });
                grd.RowDefinitions.Add(new RowDefinition());
                _transactionsListView = new FastListView
                {
                    HasUnevenRows = true,
                    ItemTemplate  = new DataTemplate(() =>
                    {
                        var viewCell = new ViewCell();
                        var item     = new MenuItem
                        {
                            Text = "test"
                        };
                        item.SetBinding(MenuItem.CommandProperty, new Binding("BindingContext.RepeatCommand", source: _transactionsListView));
                        item.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
                        viewCell.ContextActions.Add(item);
                        var lbl = new Label();
                        lbl.SetBinding(Label.TextProperty, "Name");
                        viewCell.View = lbl;
                        return(viewCell);
                    })
                };
                _transactionsListView.SetBinding(ListView.ItemsSourceProperty, "Items");

                grd.Children.Add(new Label
                {
                    Text = "Click 'Scroll To' and go back"
                });

                var btn = new Button
                {
                    Text         = "Scroll to",
                    AutomationId = _btnScrollToId,
                    Command      = new Command(() =>
                    {
                        var item = _viewModel.Items.Skip(250).First();
                        _transactionsListView.ScrollTo(item, ScrollToPosition.MakeVisible, false);
                    })
                };

                Grid.SetRow(btn, 1);
                grd.Children.Add(btn);
                Grid.SetRow(_transactionsListView, 2);
                grd.Children.Add(_transactionsListView);

                Content = grd;


                BindingContext = _viewModel;
            }
Ejemplo n.º 3
0
        private void CreateDestroyList()
        {
            this.SuspendLayout();

            if (ShouldCreateAdvancedListView())
            {
                // create advanced list if required
                if (InnerAdvList == null)
                {
                    InnerAdvList = new AdvancedListView();
                    ConfigureList(InnerAdvList);
                }

                // destroy fast list if created
                if (InnerFastList != null)
                {
                    this.Controls.Remove(InnerFastList);
                    InnerFastList.Dispose();
                    InnerFastList = null;
                }
            }
            else
            {
                // else create fast list
                if (InnerFastList == null)
                {
                    InnerFastList = new FastListView();
                    ConfigureList(InnerFastList);
                }

                // destroy advanced list if created
                if (InnerAdvList != null)
                {
                    this.Controls.Remove(InnerAdvList);
                    InnerAdvList.Dispose();
                    InnerAdvList = null;
                }
            }

            this.ResumeLayout();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create groups for FastListView
        /// </summary>
        /// <param name="parmameters"></param>
        /// <returns></returns>
        public override IList <OLVGroup> GetGroups(GroupingParameters parmameters)
        {
            // There is a lot of overlap between this method and FluentListView.MakeGroups()
            // Any changes made here may need to be reflected there

            // This strategy can only be used on FastFluentListViews
            FastListView folv = (FastListView)parmameters.ListView;

            // Separate the list view items into groups, using the group key as the descrimanent
            int objectCount = 0;
            NullableDictionary <object, List <object> > map = new NullableDictionary <object, List <object> >();

            foreach (object model in folv.FilteredObjects)
            {
                object key = parmameters.GroupByColumn.GetGroupKey(model);
                if (!map.ContainsKey(key))
                {
                    map[key] = new List <object>();
                }
                map[key].Add(model);
                objectCount++;
            }

            // Sort the items within each group
            // TODO: Give parameters a ModelComparer property
            OLVColumn           primarySortColumn = parmameters.SortItemsByPrimaryColumn ? parmameters.ListView.GetColumn(0) : parmameters.PrimarySort;
            ModelObjectComparer sorter            = new ModelObjectComparer(primarySortColumn, parmameters.PrimarySortOrder,
                                                                            parmameters.SecondarySort, parmameters.SecondarySortOrder);

            foreach (object key in map.Keys)
            {
                map[key].Sort(sorter);
            }

            // Make a list of the required groups
            List <OLVGroup> groups = new List <OLVGroup>();

            foreach (object key in map.Keys)
            {
                string title = parmameters.GroupByColumn.ConvertGroupKeyToTitle(key);
                if (!String.IsNullOrEmpty(parmameters.TitleFormat))
                {
                    int    count  = map[key].Count;
                    string format = (count == 1 ? parmameters.TitleSingularFormat : parmameters.TitleFormat);
                    try {
                        title = String.Format(format, title, count);
                    } catch (FormatException) {
                        title = "Invalid group format: " + format;
                    }
                }
                OLVGroup lvg = new OLVGroup(title);
                lvg.Collapsible      = folv.HasCollapsibleGroups;
                lvg.Key              = key;
                lvg.SortValue        = key as IComparable;
                lvg.Contents         = map[key].ConvertAll <int>(delegate(object x) { return(folv.IndexOf(x)); });
                lvg.VirtualItemCount = map[key].Count;
                if (parmameters.GroupByColumn.GroupFormatter != null)
                {
                    parmameters.GroupByColumn.GroupFormatter(lvg, parmameters);
                }
                groups.Add(lvg);
            }

            // Sort the groups
            if (parmameters.GroupByOrder != SortOrder.None)
            {
                groups.Sort(parmameters.GroupComparer ?? new OLVGroupComparer(parmameters.GroupByOrder));
            }

            // Build an array that remembers which group each item belongs to.
            this.indexToGroupMap = new List <int>(objectCount);
            this.indexToGroupMap.AddRange(new int[objectCount]);

            for (int i = 0; i < groups.Count; i++)
            {
                OLVGroup   group   = groups[i];
                List <int> members = (List <int>)group.Contents;
                foreach (int j in members)
                {
                    this.indexToGroupMap[j] = i;
                }
            }

            return(groups);
        }