Net Maui when I clicked ( 3 times ) the button multiple page ( 3 times ) comes that has to be only one page..

Net Maui when I clicked ( 3 times ) the button multiple page ( 3 times ) comes that has to be only one page.. any solution ?
Thanks
.NET MAUI
-
Viorel • 119.9K Reputation points
2023-01-19T05:45:10.1433333+00:00 Show some details about the button and the code. How should it behave in case of '2 times' and other number of clicks?
-
Sami • 966 Reputation points
2023-01-20T04:51:08.7266667+00:00 forexample custom buttons
firstly I have created custom view button
public partial class CustomButton : ContentView { public CustomButton() { InitializeComponent(); } public static readonly BindableProperty PanelAvatarProperty = BindableProperty.Create( nameof(PanelAvatar), typeof(ImageSource), typeof(CustomButton), null, BindingMode.TwoWay, propertyChanged: PanelAvatarChanged); public ImageSource PanelAvatar { get => (ImageSource)GetValue(PanelAvatarProperty); set => SetValue(PanelAvatarProperty, value); } private static void PanelAvatarChanged(BindableObject bindable, object oldValue, object newValue) { CustomButtom control = bindable as CustomButtom; control.imgAvatar.Source = newValue as ImageSource; } public event EventHandler<EventArgs> CustomButtonClickEvent; public void OpenPage_Tapped(object sender, EventArgs e) { if (CustomButtonClickEvent != null) this.CustomButtonClickEvent(this, new EventArgs()); } }
xml...
<custom:ButtonView x:Name=''btnCustom'' />
C#
public partial class Profile : ContentPage { public Profile() { InitializeComponent(); btnCustom.CustomButtonClickEvent += BtnProfile_CustomButtonClickEvent; } private async void BtnProfile_CustomButtonClickEvent(object sender, EventArgs e) { var btn = (CustomButton)sender; if (btn.Name == "btnAvatar") { await popupAvatar.OpenPopupDrawer(); } } }
also if content inside of page that while opening delay (not opening as quick as expected ) ?
-
Leon Lu (Shanghai Wicresoft Co,.Ltd.) • 79,781 Reputation points • Microsoft Vendor
2023-01-20T05:14:51+00:00 @Sami Could you share code about
await popupAvatar.OpenPopupDrawer();
? If the page cannot be opened immediately, is there any time-consuming operation in thisawait popupAvatar.OpenPopupDrawer();
? It is not recommended that execute time-consuming operation in UI thread. -
Sami • 966 Reputation points
2023-01-23T02:16:58.9166667+00:00 codes is the same as this just name instead of OpenBottomSheet() ........... OpenPopupDrawer()
[https://github.com/naweed/Maui.Controls.BottomSheet/tree/main/src
thanks
-
Leon Lu (Shanghai Wicresoft Co,.Ltd.) • 79,781 Reputation points • Microsoft Vendor
2023-01-24T08:17:58.1633333+00:00 When you click muti-times button at one time, the pop-up window will be slow and choked, am I right?
-
Sami • 966 Reputation points
2023-01-30T01:09:48.5966667+00:00 I don t have any problem with popup it is working fine when open a navigation page when clicked 3 times opening page 3 times
async void Button_Click(object sender, EventArgs e) { await Navigation.PushAsync(new AccountPage()); }
-
Leon Lu (Shanghai Wicresoft Co,.Ltd.) • 79,781 Reputation points • Microsoft Vendor
2023-01-30T08:22:08.1533333+00:00 @Sami Do you want to avoid multiple clicks?
-
Sami • 966 Reputation points
2023-01-31T09:03:21.3533333+00:00 Yes How to stop it ?
-
Sami • 966 Reputation points
2023-01-31T09:03:34.1166667+00:00 Yes how to stop this ?
-
Leon Lu (Shanghai Wicresoft Co,.Ltd.) • 79,781 Reputation points • Microsoft Vendor
2023-01-31T09:36:08.51+00:00 Could you expose a method or event to detect the BottomSheet appear or disappear? If so, you can create a bool property, binding the property to the button's
IsEnable
, when the BottomSheet is appear, set the button'sisEnable
to false, when the BottomSheet is disappear, set the button'sisEnable
to true. -
Sami • 966 Reputation points
2023-01-31T09:42:12.5566667+00:00 There is no problem with bottomsheet it is working as expected.
when I click ( 2 - 3 times ) button in net maui as below page is opening 2 - 3 times
async void Button_Click(object sender, EventArgs e) { await Navigation.PushAsync(new AccountPage()); }
-
Leon Lu (Shanghai Wicresoft Co,.Ltd.) • 79,781 Reputation points • Microsoft Vendor
2023-02-01T07:28:35.7033333+00:00 Before you navigate to the accountpage, you can loop the NavigationStack, check if AccountPage in the NavigationStack like following code
if (Navigation.NavigationStack.Count == 0 || Navigation.NavigationStack.Last().GetType() != typeof(AccountPage)) { await Navigation.PushAsync(new AccountPage(), true); }
Sign in to comment