コード例 #1
0
 protected override void OnDetachingFrom(SampleView bindable)
 {
     ListView.SelectionChanged -= ListView_SelectionChanged;
     ListView            = null;
     gridLayout          = null;
     deleteImageParent   = null;
     headerGrid          = null;
     gridLayoutViewModel = null;
     base.OnDetachingFrom(bindable);
 }
コード例 #2
0
        protected override void OnAttachedTo(SampleView bindable)
        {
            ListView = bindable.FindByName <Syncfusion.ListView.XForms.SfListView>("listView");
            ListView.SelectionChanged += ListView_SelectionChanged;

            gridLayoutViewModel     = new ListViewGridLayoutViewModel();
            ListView.BindingContext = gridLayoutViewModel;
            ListView.ItemsSource    = gridLayoutViewModel.Gallerynfo;

            headerGrid = bindable.FindByName <Grid>("headerGrid");
            headerGrid.BindingContext = gridLayoutViewModel;

            deleteImageParent = bindable.FindByName <Grid>("deleteImageParent");
            var deleteImageTapped = new TapGestureRecognizer()
            {
                Command = new Command(DeleteImageTapped_tapped)
            };

            deleteImageParent.GestureRecognizers.Add(deleteImageTapped);

            gridLayout = new Syncfusion.ListView.XForms.GridLayout();

            if (Device.RuntimePlatform == Device.Android || Device.RuntimePlatform == Device.iOS)
            {
                gridLayout.SpanCount = Device.Idiom == TargetIdiom.Phone ? 2 : 4;
                ListView.ItemSize    = Device.Idiom == TargetIdiom.Phone || Device.Idiom == TargetIdiom.Tablet ? 150 : 170;
            }
            else if (Device.RuntimePlatform == Device.macOS)
            {
                gridLayout.SpanCount = 4;
                ListView.ItemSize    = 300;
            }
            else if (Device.RuntimePlatform == Device.UWP)
            {
                gridLayout.SpanCount = Device.Idiom == TargetIdiom.Desktop || Device.Idiom == TargetIdiom.Tablet ? 4 : 2;
                ListView.ItemSize    = Device.Idiom == TargetIdiom.Desktop || Device.Idiom == TargetIdiom.Tablet ? 300 : 140;
            }

            ListView.LayoutManager = gridLayout;
            ListView.DataSource.GroupDescriptors.Add(new GroupDescriptor()
            {
                PropertyName = "CreatedDate"
            });

            base.OnAttachedTo(bindable);
        }