private void RegisterCommands()
        {
            ReviewAppCommand = new Command(async (p) =>
            {
                
                try
                {
                    // Get the package family name
                    var packageFamilyName = Windows.ApplicationModel.Package.Current.Id.FamilyName;
                    // Launch the uri
                    await Windows.System.Launcher.LaunchUriAsync(new Uri($"ms-windows-store:REVIEW?PFN={packageFamilyName}"));

                }
                catch (Exception)
                {
                    // Failed
                    await DialogHelper.ShowMessageDialogAsync("Could not launch the requested url.");
                }

                

            });

            SubmitIssueCommand = new Command(async (p) =>
            {
                try
                {
                    // Launch the uri
                    await Windows.System.Launcher.LaunchUriAsync(new Uri(IssuesUri));

                }
                catch (Exception)
                {
                    // Failed
                    await DialogHelper.ShowMessageDialogAsync("Could not launch the requested url.");
                }


            });
        }
 /// <summary>
 /// Register commands
 /// </summary>
 private void RegisterCommands()
 {
     LogInCommand = new Command(LogInCommandHandler, IsLoginEnabled);
     CreateAccountCommand = new Command(CreateAccountCommandHandler);
     GoToFacebookCommand = new Command(GoToFacebookCommandHandler);
     GoToTwitterCommand = new Command(GoToTwitterCommandHandler);
 }
        /// <summary>
        /// Registers commands for UI elements
        /// </summary>
        private void RegisterCommands()
        {
            // Handle add category
            AddCategoryCommand = new Command(async (p) =>
            {
                // Prompt for name
                await DialogHelper.ShowClosableDialog<NamePromptDialog>(async (d) =>
                {
                    try
                    {
                        //create new category
                        var category = new ApiCategory()
                        {
                            Name = d.Value
                        };

                        // Send the category to the api
                        var resp = await KryptPadApi.SaveCategoryAsync(category);

                        // Set the id of the newly created category
                        category.Id = resp.Id;

                        // Add the category to the list
                        Categories.Add(category);

                        // Add view to the ItemsView object
                        ItemsView.Source = Categories;

                        // Refresh
                        OnPropertyChanged(nameof(ItemsView));

                        // Hide empty message
                        EmptyMessageVisibility = Visibility.Collapsed;
                    }
                    catch (WebException ex)
                    {
                        // Something went wrong in the api
                        await DialogHelper.ShowMessageDialogAsync(ex.Message);
                    }
                    catch (Exception)
                    {
                        // Failed
                        await DialogHelper.ShowConnectionErrorMessageDialog();
                    }

                }, "Add Category");
            });

            // Handle add new item
            AddItemCommand = new Command(AddItemCommandHandler);

            // Handle item click
            ItemClickCommand = new Command((p) =>
            {
                var item = p as ApiItem;
                var category = (from c in Categories
                                where c.Items.Contains(item)
                                select c).FirstOrDefault();

                // Navigate to edit
                NavigationHelper.Navigate(typeof(NewItemPage),
                    new EditItemPageParams()
                    {
                        Category = category,
                        Item = item
                    });


            });

            // Handle change passphrase command
            ChangePassphraseCommand = new Command(async (p) =>
            {

                var dialog = new ChangePassphraseDialog();

                await dialog.ShowAsync();

            });

            // Handle rename command
            RenameProfileCommand = new Command(async (p) =>
            {

                // Prompt for name
                await DialogHelper.ShowNameDialog(async (d) =>
                {
                    try
                    {
                        // Set new name
                        var profile = KryptPadApi.CurrentProfile;
                        profile.Name = d.Value;

                        // Send the category to the api
                        var resp = await KryptPadApi.SaveProfileAsync(profile);

                    }
                    catch (WebException ex)
                    {
                        // Something went wrong in the api
                        await DialogHelper.ShowMessageDialogAsync(ex.Message);
                    }
                    catch (Exception)
                    {
                        // Failed
                        await DialogHelper.ShowConnectionErrorMessageDialog();
                    }
                }, "RENAME PROFILE", KryptPadApi.CurrentProfile.Name);
            });

            // Handle delete command
            DeleteProfileCommand = new Command(async (p) =>
            {

                var res = await DialogHelper.Confirm(
                    "All of your data in this profile will be deleted permanently. THIS ACTION CANNOT BE UNDONE. Are you sure you want to delete this entire profile?",
                    "WARNING - CONFIRM DELETE",
                    async (ap) =>
                    {
                        try
                        {
                            // Delete the selected profile
                            await KryptPadApi.DeleteProfileAsync(KryptPadApi.CurrentProfile);

                            // Navigate back to the profiles list
                            NavigationHelper.Navigate(typeof(SelectProfilePage), null);

                            // Clear backstack
                            NavigationHelper.ClearBackStack();

                        }
                        catch (WebException ex)
                        {
                            // Something went wrong in the api
                            await DialogHelper.ShowMessageDialogAsync(ex.Message);
                        }
                        catch (Exception)
                        {
                            // Failed
                            await DialogHelper.ShowConnectionErrorMessageDialog();
                        }

                    }
                );


            });

            // Download profile handler
            DownloadProfileCommand = new Command(async (prop) =>
            {
                try
                {
                    // Prompt for a place to save the file
                    var sfd = new FileSavePicker()
                    {
                        SuggestedFileName = KryptPadApi.CurrentProfile.Name,

                    };

                    //sfd.FileTypeChoices.Add("KryptPad Document Format", new List<string>(new[] { ".kdf" }));
                    sfd.FileTypeChoices.Add("KryptPad Document Format", new[] { ".kdf" });

                    // Show the picker
                    var file = await sfd.PickSaveFileAsync();

                    if (file != null)
                    {

                        // Get profile
                        var profileData = await KryptPadApi.DownloadCurrentProfileAsync();

                        // Save profile to file
                        using (var fs = await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite))
                        using (var sw = new StreamWriter(fs.AsStreamForWrite()))
                        {
                            // Write the data
                            sw.Write(profileData);
                        }

                        await DialogHelper.ShowMessageDialogAsync("Profile downloaded successfully");
                    }
                }
                catch (WebException ex)
                {
                    // Something went wrong in the api
                    await DialogHelper.ShowMessageDialogAsync(ex.Message);
                }
                catch (Exception)
                {
                    // Failed
                    await DialogHelper.ShowConnectionErrorMessageDialog();
                }

            });

            // Handle category rename
            RenameCategoryCommand = new Command(RenameCategoryCommandHandler);

            // Handle category delete
            DeleteCategoryCommand = new Command(DeleteCategoryCommandHandler);

            // Handle selection mode
            SelectModeCommand = new Command(SelectModeCommandHandler);

            // Handle the move command
            MoveItemsCommand = new Command(MoveItemsCommandHandler, CanMoveItems);
        }
        /// <summary>
        /// Register commands
        /// </summary>
        private void RegisterCommands()
        {


            CreateAccountCommand = new Command(async (p) =>
            {
                IsBusy = true;
                try
                {
                    // Log in and get access token
                    var response = await KryptPadApi.CreateAccountAsync(Email, Password, ConfirmPassword);

                    // The account was created
                    await DialogHelper.ShowMessageDialogAsync("Your account has been successfully created.");

                    // Go to login page
                    NavigationHelper.Navigate(typeof(LoginPage), null);

                    // Clear backstack
                    NavigationHelper.ClearBackStack();

                }
                catch (WebException ex)
                {
                    // Something went wrong in the api
                    await DialogHelper.ShowMessageDialogAsync(ex.Message);
                }
                catch (Exception)
                {
                    // Failed
                    await DialogHelper.ShowConnectionErrorMessageDialog();
                }


                IsBusy = false;

            }, CanSignUp);
        }
        /// <summary>
        /// Registers commands
        /// </summary>
        private void RegisterCommands()
        {
            CreateProfileCommand = new Command(async (p) =>
            {
                // Prompt the user for profile info
                var dialog = new ProfileDetailsDialog();

                var result = await dialog.ShowAsync();
            });

            EnterProfileCommand = new Command(async (p) =>
            {
                try
                {
                    // Check the profile and determine if the passphrase is correct
                    await KryptPadApi.LoadProfileAsync(SelectedProfile, Passphrase);

                    // Success, tell the app we are signed in
                    (App.Current as App).IsSignedIn = true;

                    // When a profile is selected, navigate to main page
                    NavigationHelper.Navigate(typeof(ItemsPage), null);

                }
                catch (WebException)
                {
                    // Something went wrong in the api
                    await DialogHelper.ShowMessageDialogAsync("The passphrase you entered is incorrect.");

                    // Clear out the passphrase
                    Passphrase = null;
                }
                catch (Exception)
                {
                    // Failed
                    await DialogHelper.ShowConnectionErrorMessageDialog();
                }
            }, CanLogIn);

            RestoreBackupCommand = new Command(async (p) =>
            {
                try
                {
                    var fop = new FileOpenPicker();
                    // Add supported file types
                    fop.FileTypeFilter.Add(".kdf");

                    // Pick file to open and read
                    var result = await fop.PickSingleFileAsync();

                    if (result != null)
                    {
                        var fs = await result.OpenReadAsync();
                        string profileData;
                        // Create a stream reader
                        using (var sr = new StreamReader(fs.AsStreamForRead()))
                        {
                            profileData = await sr.ReadToEndAsync();

                        }

                        // Upload the profile data
                        var resp = await KryptPadApi.UploadProfile(profileData);

                        await DialogHelper.ShowMessageDialogAsync("Profile restored successfully");

                        await GetProfilesAsync();

                    }
                }
                catch (WebException ex)
                {
                    // Something went wrong in the api
                    await DialogHelper.ShowMessageDialogAsync(ex.Message);
                }
                catch (Exception)
                {
                    // Failed
                    await DialogHelper.ShowConnectionErrorMessageDialog();
                }


            });
        }
        /// <summary>
        /// Registers commands for UI elements
        /// </summary>
        private void RegisterCommands()
        {

            // Handle add new field
            AddFieldCommand = new Command(async (p) =>
            {

                // Show the add field dialog
                var res = await DialogHelper.ShowClosableDialog<AddFieldDialog>(async (d) =>
                {

                    try
                    {
                        var m = (d.DataContext as AddFieldDialogViewModel);
                        var field = new FieldModel(new ApiField()
                        {
                            Name = m.FieldName,
                            FieldType = m.SelectedFieldType.Id
                        });

                        // Send the field to the API to be stored under the item
                        var resp = await KryptPadApi.SaveFieldAsync(Category.Id, Item.Id, field.Field);

                        field.Id = resp.Id;

                        // Add field to the list
                        AddFieldToCollection(field);
                    }
                    catch (WebException ex)
                    {
                        // Something went wrong in the api
                        await DialogHelper.ShowMessageDialogAsync(ex.Message);
                    }
                    catch (Exception)
                    {
                        // Failed
                        await DialogHelper.ShowConnectionErrorMessageDialog();
                    }


                });


            });

            // Handle item delete
            DeleteItemCommand = new Command(async (p) =>
            {

                // Prompt user to delete the item
                var promptResp = await DialogHelper.Confirm(
                    "This action cannot be undone. All data associated with this item will be deleted. Are you sure you want to delete this item?",
                    async (c) =>
                    {
                        try
                        {
                            // Delete the item
                            await KryptPadApi.DeleteItemAsync(Category.Id, Item.Id);

                            // Navigate back to items page
                            NavigationHelper.Navigate(typeof(ItemsPage), null);

                        }
                        catch (WebException ex)
                        {
                            // Something went wrong in the api
                            await DialogHelper.ShowMessageDialogAsync(ex.Message);
                        }
                        catch (Exception)
                        {
                            // Failed
                            await DialogHelper.ShowConnectionErrorMessageDialog();
                        }
                    });

            });

            // Handle copy field value
            CopyFieldValueCommand = new Command(async (p) =>
            {
                try
                {
                    var field = p as FieldModel;
                    // Check if field value is null
                    if (!string.IsNullOrWhiteSpace(field.Value))
                    {
                        // Create a data package
                        var package = new DataPackage();
                        package.SetText(field.Value);

                        // Set the value of the field to the clipboard
                        Clipboard.SetContent(package);
                    }
                }
                catch (Exception)
                {
                    // Failed
                    await DialogHelper.ShowMessageDialogAsync("Failed to copy text to clipboard.");
                }

            });

            // Delete field
            DeleteFieldCommand = new Command(DeleteFieldCommandHandler);

            // Rename field
            RenameFieldCommand = new Command(RenameFieldCommandHandler);

            // Generate password
            GeneratePasswordCommand = new Command(GeneratePasswordCommandHandler);
        }