private async void SaveFeatureCollectionFromQuery()
        {
            Debug.WriteLine("Creating feature collection from the service...");

            // Create a service feature table to get features from
            ServiceFeatureTable featTable = new ServiceFeatureTable(new Uri(FeatureLayerUrl));

            // Create a query to get all features in the table
            QueryParameters queryParams = new QueryParameters();

            queryParams.WhereClause = "1=1";

            // Query the table to get all features
            FeatureQueryResult featureResult = await featTable.QueryFeaturesAsync(queryParams);

            // Create a new feature collection table from the result features
            FeatureCollectionTable collectTable = new FeatureCollectionTable(featureResult);

            // Create a feature collection and add the table
            FeatureCollection featCollection = new FeatureCollection();

            featCollection.Tables.Add(collectTable);


            var tokenServiceUri = new Uri("https://www.arcgis.com/sharing/rest");  // url for generating token

            AuthenticationManager authManager = AuthenticationManager.Current;
            var cred = await authManager.GenerateCredentialAsync(tokenServiceUri, "*******", "*******");

            // Open a portal item containing a feature collection
            ArcGISPortal portal = await ArcGISPortal.CreateAsync(tokenServiceUri, cred);

            List <string> str = new List <string>();

            str.Add("Save Feature collection");


            FeatureCollectionLayer featCollectionTable = new FeatureCollectionLayer(featCollection);
            await featCollectionTable.LoadAsync();

            MyMapView.Map.OperationalLayers.Add(featCollectionTable);

            Debug.WriteLine("Create a feature layer named, Feature Collection to Portal, and saving to portal...");

            try
            {
                await featCollection.SaveAsAsync(portal, null, "Feature Collection to Portal", "FeatureCollection", str);

                MessageBox.Show("Feature Collection saved to portal");
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }