private bool FilterPredicate(object value)
        {
            var toCompare = QueryText != null?QueryText.ToLower() : string.Empty;

            var customer = ((GroupMemberItem)value).Customer;

            if (FilterItemsSource != null && FilterItemsSource.Any(x => x.Customer.GlobalId == customer.GlobalId))
            {
                return(false);
            }
            return(customer.FirstName.SafeStartsWith(toCompare) ||
                   customer.LastName.SafeStartsWith(toCompare) ||
                   customer.Email.SafeStartsWith(toCompare));
        }
예제 #2
0
        private void Init()
        {
            IList enumerable = ItemsSource as IList ?? ItemsSource?.Cast <object>()?.ToArray();

            // Register for itemsource change
            AddCollectionChanged(enumerable);

            // Clear added items if no items exists anymore
            if (!(enumerable?.Count > 0))
            {
                // Clear items
                if (Children.LastOrDefault() is ScrollView scroll)
                {
                    scroll.Content = null;
                }

                return;
            }

            this.ColumnSpacing = 0;
            this.RowSpacing    = 0;

            this.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });
            this.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Star
            });

            var headerGrid = new Grid()
            {
                ColumnSpacing = 0
            };

            // Adding headers
            foreach (var templateView in ItemTemplates)
            {
                if (FilterItemsSource?.Any() == true && FilterItemsSource?.Any(x => x.Id == templateView.Id && !x.IsVisible) == true)
                {
                    continue;
                }

                var headerView = GetView(templateView.HeaderTemplateSource);

                SetColumn(headerView, headerGrid.ColumnDefinitions.Count);

                headerGrid.Children.Add(headerView);

                headerGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = ScrollOrientation == ScrollOrientation.Vertical ? GridLength.Star : GridLength.Auto
                });
            }

            var itemsGrid = new Grid()
            {
                ColumnSpacing     = 0,
                RowSpacing        = 0,
                ColumnDefinitions = headerGrid.ColumnDefinitions
            };

            // Adding items
            foreach (var item in enumerable)
            {
                var properties = item.GetType().GetProperties();

                var columnPosition = 0;

                foreach (var property in properties)
                {
                    var columnView = ItemTemplates.FirstOrDefault(x => x.Id == property.Name);

                    if (FilterItemsSource?.Any() == true && FilterItemsSource?.Any(x => x.Id == columnView.Id && !x.IsVisible) == true)
                    {
                        continue;
                    }

                    var itempropertyView = GetView(columnView.ItemTemplateSource, item);

                    itempropertyView.BindingContext = item;

                    SetRow(itempropertyView, itemsGrid.RowDefinitions.Count);
                    SetColumn(itempropertyView, columnPosition);

                    itempropertyView.BackgroundColor = StripedBackground ? (itemsGrid.RowDefinitions.Count % 2 == 0 ? SecondBackground : itempropertyView.BackgroundColor) : itempropertyView.BackgroundColor;

                    itemsGrid.Children.Add(itempropertyView);

                    columnPosition++;
                }

                itemsGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });
            }

            Children.Add(headerGrid);

            var scrollview = new ScrollView
            {
                Content     = itemsGrid,
                Orientation = ScrollOrientation
            };

            SetRow(scrollview, 1);

            Children.Add(scrollview);
        }