You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using System.ComponentModel;
using Xamarin.Forms;
using GenTurfEvo.ViewModel;
using System.Threading.Tasks;
using System;
using Rg.Plugins.Popup.Pages;
using Rg.Plugins.Popup.Services;
namespace GenTurfEvo.Views
{
// Learn more about making custom code visible in the Xamarin.Forms previewer
// by visiting https://aka.ms/xamarinforms-previewer
[DesignTimeVisible(false)]
public partial class MainPage : ContentPage
{
private readonly MainPageViewModel _viewModel;
public MainPage()
{
InitializeComponent();
BindingContext = _viewModel = new MainPageViewModel();
}
private async void OnFrameTapped(object sender, EventArgs e)
{
// Afficher la popup avec le DatePicker
await DisplayDatePickerPopup(this);
}
private async void OnCancelButtonClicked(object sender, EventArgs e)
{
await PopupNavigation.Instance.PopAsync();
}
private async void OnConfirmButtonClicked(object sender, EventArgs e)
{
// Traiter la date sélectionnée
await PopupNavigation.Instance.PopAsync();
}
private async Task DisplayDatePickerPopup(MainPage mainPage)
{
var customDatePickerPopup = new CustomDatePickerPopup(mainPage);
await PopupNavigation.Instance.PushAsync(customDatePickerPopup);
}
private class CustomDatePickerPopup : PopupPage
{
private readonly MainPage _mainPage;
public CustomDatePickerPopup(MainPage mainPage)
{
_mainPage = mainPage;
var datePicker = new DatePicker
{
Format = "dd/MM/yyyy",
MaximumDate = DateTime.Now
};
var cancelButton = new Button { Text = "Annuler" };
var confirmButton = new Button { Text = "Valider" };
cancelButton.Clicked += _mainPage.OnCancelButtonClicked;
confirmButton.Clicked += _mainPage.OnConfirmButtonClicked;
Content = new StackLayout
{
Children = { datePicker, cancelButton, confirmButton },
Padding = new Thickness(20)
};
}
}
}
}
My call on MainPage.xaml :
<!-- Date des courses -->
<Frame Grid.Row="0" Grid.Column="1" Margin="1,1,1,0" Padding="5,0" BackgroundColor="Green" BorderColor="Orange">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="OnFrameTapped" />
</Frame.GestureRecognizers>
<Label FontSize="18" FontFamily="NunitoSemiBold" FontAttributes="Bold" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Text="Sélectionner une date" TextColor="{StaticResource colorWhite}" />
</Frame>
```### Expected behavior
Detail of error after call OnFrameTapped :
Rg.Plugins.Popup.Exceptions.RGInitialisationException
Message=You MUST call Rg.Plugins.Popup.Popup.Init(); prior to using it.
See more info: https://github.com/rotorgames/Rg.Plugins.Popup/wiki/Getting-started#initialization
Source=mscorlib
Arborescence des appels de procédure :
at Rg.Plugins.Popup.Services.PopupNavigationImpl.get_PopupPlatform () [0x0001d] in Z:\Documents\OpenSource\Rg.Plugins.Popup\Rg.Plugins.Popup\Services\PopupNavigationImpl.cs:35
at Rg.Plugins.Popup.Services.PopupNavigationImpl..ctor () [0x0001c] in Z:\Documents\OpenSource\Rg.Plugins.Popup\Rg.Plugins.Popup\Services\PopupNavigationImpl.cs:45
at Rg.Plugins.Popup.Services.PopupNavigation.get_Instance () [0x00014] in Z:\Documents\OpenSource\Rg.Plugins.Popup\Rg.Plugins.Popup\Services\PopupNavigation.cs:30
at GenTurfEvo.Views.MainPage.DisplayDatePickerPopup (GenTurfEvo.Views.MainPage mainPage) [0x00020] in C:\NewTurf\GenTurfEvo\GenTurfEvo\Views\MainPage.xaml.cs:42
at GenTurfEvo.Views.MainPage.OnFrameTapped (System.Object sender, System.EventArgs e) [0x00026] in C:\NewTurf\GenTurfEvo\GenTurfEvo\Views\MainPage.xaml.cs:25
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021
at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:36
at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36
at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-33/mcw/Java.Lang.IRunnable.cs:84
at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V (_JniMarshal_PP_V callback, System.IntPtr jnienv, System.IntPtr klazz) [0x00005] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:22
at (wrapper native-to-managed) Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(intptr,intptr)
### Reproduction steps
### Configuration
Visual studio 2022 last version
Last version on all nugets packages
Rg.Plugins.Popup Version : 2.1
**Platform:**
- [ ] :robot: Android
The text was updated successfully, but these errors were encountered:
🐛 Bug Report
Projet Xamarin android and ios
My MainPAge.xaml.cs :
My call on MainPage.xaml :
The text was updated successfully, but these errors were encountered: