public NathanPicker() { BindingContext = new PickerItem(); IsVisible = false; PickerViewModel = new PickerViewModel(); _headerLayout = new HeaderLayout(); _headerLayout.TapGestureRecognizerSearchImage.Tapped += (s, e) => { _myCollectionView.ScrollTo(0); _headerLayout.TitleImage.IsVisible = false; _headerLayout.TitleLabel.IsVisible = false; _headerLayout.SearchImage.IsVisible = false; _headerLayout.PickerSearchBar.IsVisible = true; _headerLayout.BackImage.IsVisible = true; new Animation(d => _headerLayout.PickerSearchBar.Opacity = d, 0.5, 1).Commit(_headerLayout.PickerSearchBar, "SearchBar Animation", 60, 300, Easing.CubicOut); }; _headerLayout.TapGestureRecognizerBackImage.Tapped += (s, e) => { _myCollectionView.ScrollTo(0); _headerLayout.SearchImage.IsVisible = true; _headerLayout.PickerSearchBar.Text = ""; _headerLayout.TitleImage.IsVisible = true; _headerLayout.TitleLabel.IsVisible = true; _headerLayout.PickerSearchBar.IsVisible = false; _headerLayout.BackImage.IsVisible = false; }; _headerLayout.PickerSearchBar.TextChanged += OnPickerSearchBarTextChanged; var emptyViewLabel = new Label { HorizontalOptions = LayoutOptions.Fill, HorizontalTextAlignment = TextAlignment.Center, FontSize = DFDesignMainPage.PickerTitleFontSize.Value }; emptyViewLabel.SetBinding(Label.TextProperty, "CurrentSearch"); _myCollectionView = new CollectionView { ItemsSource = PickerViewModel.PickerItems, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, SelectionMode = SelectionMode.Single, ItemTemplate = new DataTemplate(() => new CollectionCellLayout()), EmptyView = new StackLayout { VerticalOptions = LayoutOptions.CenterAndExpand, Padding = new Thickness(DFDesignMainPage.emptyViewSidePadding.Value, 0, DFDesignMainPage.emptyViewSidePadding.Value, 0), Children = { emptyViewLabel } } }; _myCollectionView.SelectionChanged += OnCollectionsViewItemSelected; BottomPanContainer.FrameContentStackLayout.Children.Add(_headerLayout); BottomPanContainer.FrameContentStackLayout.Children.Add(_myCollectionView); Init(); var backgroundGesture = new TapGestureRecognizer(); backgroundGesture.Tapped += (s, e) => { if (IsVisible) { InVisiblePicker(); } }; }
public void AddItem(PickerItem pickerItem) { PickerViewModel.PickerItems.Add(pickerItem); SetItemOptionsDefault(); }