Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

MaterialMenuButton - on click application got crash in both Android and iOS #449

Open
3 of 7 tasks
divyesh008 opened this issue Jun 22, 2022 · 4 comments
Open
3 of 7 tasks

Comments

@divyesh008
Copy link

divyesh008 commented Jun 22, 2022

馃悰 Bug Report

Expected behavior

  • It should work properly and show a popup with menu items.

Reproduction steps

  • Add MaterialMenuButton on the page and when clicking on the button it crashes the app.

MainPage.xaml

<material:MaterialMenuButton
            Grid.Row="0" Grid.Column="1"
            ButtonType="Elevated"
            Image="dots_circle"
            HorizontalOptions="End"
            HeightRequest="45"
            WidthRequest="45"
            Choices="{Binding Actions}"
            Command="{Binding ActionSelectCommand}"
            BackgroundColor="Transparent"/>

MainPageViewModel.cs

public MainPageViewModel()
{
      ObservableCollection<MaterialMenuItem> actions = new ObservableCollection<MaterialMenuItem>();
      actions.Add(new MaterialMenuItem() { Text = "Details" });
      actions.Add(new MaterialMenuItem() { Text = "Edit" });
      actions.Add(new MaterialMenuItem() { Text = "Upload Document" });
      actions.Add(new MaterialMenuItem() { Text = "Add Project" });
      Actions = new ObservableCollection<MaterialMenuItem>(actions);
}

private ObservableCollection<MaterialMenuItem> _actions { get; set; }
public ObservableCollection<MaterialMenuItem> Actions
{
     get => _actions;
     set { _actions = value; OnPropertyChanged(nameof(Actions)); }
}

Configuration

  • Visual Studio for Mac 2022 Version 17.0.1 (build 72)

Version: 1.x

  • XF.Material - 1.8.0

Platform:

  • 馃摫 iOS
  • 馃 Android
  • 馃弫 WPF
  • 馃寧 UWP
  • 馃崕 MacOS
  • 馃摵 tvOS
  • 馃悞 Xamarin.Forms

Exception Message: Cannot show menu, property Choices is null or has no items

Stack Trace

at XF.Material.Forms.UI.MaterialMenuButton.OnViewTouch (System.Double x, System.Double y) [0x0002c] in Z:\Documents\OpenSource\XF-Material-Library\XF.Material\UI\MaterialMenuButton.cs:131 
  at XF.Material.iOS.Renderers.MaterialMenuRenderer.OnClick () [0x0001b] in Z:\Documents\OpenSource\XF-Material-Library\XF.Material\Platforms\Ios\Renderers\MaterialMenuRenderer.cs:26 
  at Xamarin.Forms.Command+<>c__DisplayClass4_0.<.ctor>b__0 (System.Object o) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Command.cs:74 
  at Xamarin.Forms.Command.Execute (System.Object parameter) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Command.cs:112 
  at XF.Material.Forms.UI.MaterialIconButton.OnButtonClicked (System.Boolean handled) [0x00017] in Z:\Documents\OpenSource\XF-Material-Library\XF.Material\UI\MaterialIconButton.xaml.cs:145 
  at XF.Material.Forms.UI.MaterialMenuButton.OnButtonClicked (System.Boolean handled) [0x00000] in Z:\Documents\OpenSource\XF-Material-Library\XF.Material\UI\MaterialMenuButton.cs:120 
  at XF.Material.Forms.UI.MaterialIconButton.<.ctor>b__13_0 () [0x00000] in Z:\Documents\OpenSource\XF-Material-Library\XF.Material\UI\MaterialIconButton.xaml.cs:47 
  at Xamarin.Forms.Command+<>c__DisplayClass4_0.<.ctor>b__0 (System.Object o) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Command.cs:74 
  at Xamarin.Forms.Command.Execute (System.Object parameter) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Command.cs:112 
  at Xamarin.Forms.ButtonElement.ElementClicked (Xamarin.Forms.VisualElement visualElement, Xamarin.Forms.Internals.IButtonElement ButtonElementManager) [0x00008] in D:\a\1\s\Xamarin.Forms.Core\ButtonElement.cs:60 
  at Xamarin.Forms.Button.SendClicked () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Button.cs:173 
  at Xamarin.Forms.Platform.iOS.ButtonElementManager.OnButtonTouchUpInside (Xamarin.Forms.IButtonController element) [0x00009] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ButtonElementManager.cs:86 
  at Xamarin.Forms.Platform.iOS.ButtonRenderer.OnButtonTouchUpInside (System.Object sender, System.EventArgs eventArgs) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ButtonRenderer.cs:189 
  at UIKit.UIControlEventProxy.Activated () [0x00004] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIControl.cs:38 
--- End of stack trace from previous location where exception was thrown ---

  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00013] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:75 
  at solarcrm.Application.Main (System.String[] args) [0x0001b] in /Users/divyeshbhatt/Documents/sourcetree/APS/src/solarcrm.Mobile.iOS/Main.cs:20 
@hpposch
Copy link

hpposch commented Jul 8, 2022

Hi
I currently have the exact same issue.
Any idea why this happens?

@divyesh008
Copy link
Author

I have recently used this control in my project and it's working fine in Xamarin Forms 5.0.0.2244

@hpposch
Copy link

hpposch commented Jul 9, 2022

Thanks for your answer, sadly it did not change anything.
No matter which version of Xamarin.Fomrs i use.
The strange thing is, that it works in some situation and in some it does not work.
I can not really determine whats the problem, the data that gets provided is always the same (List)

@divyesh008
Copy link
Author

Yes, the best way to deal with this issue is either to use paid 3rd party libraries like Syncfusion, or Telerik or else use Picker control.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants