muak / AiForms.Dialogs

AiForms.Dialogs for Xamarin.Forms
MIT License
153 stars 20 forks source link

var ret = await Dialog.Instance.ShowAsync<MyDialogView>(new { Title = "Hello" }); Error #6

Closed LinuxAndOracle closed 4 years ago

LinuxAndOracle commented 4 years ago

Your pop-up window is perfect, but at the moment when I execute it, I do n’t know where the problem is

async void OnItemSelected(object sender, SelectedItemChangedEventArgs args) { var item = args.SelectedItem as Item; if (item == null) return;

        var ret = await Dialog.Instance.ShowAsync<MyDialogView>(new { Title = "Hello" });
        // If canceled, ret is false; Otherwise is true.
        // Optionally, view model can be passed to the dialog view instance.
        // When the dialog is closed, all related resource automatically are disposed.

        // Also, IReusableDialog that keeps the state can be created.
        var reusableDialog = Dialog.Instance.Create<MyDialogView>();

        ret = await reusableDialog.ShowAsync();
        // Even if the dialog is closed, disposing process is not executed.

        if(ret)
        {
            await Navigation.PushAsync(new ItemDetailPage(new ItemDetailViewModel(item)));
        }
        else
        {

        }

        // ShowAsync can be used any number of times until disposing it.
        reusableDialog.Dispose();

        // Manually deselect item.
        ItemsListView.SelectedItem = null;
    }

The Error is: System.NullReferenceException: 'Object reference not set to an instance of an object.'