Open ninaada opened 3 years ago
Hi There,
The same here as well. I'm redoing a sample of Gerald Versluis on ToastAsync works just fine on Android, as expected, but on UWP I get a System.PlatformNotSupportedException: 'Operation is not supported on this platform.'
Code-behind: async public void OnButton_ClickMe(object sender, EventArgs args) { await this.DisplayToastAsync("Does it work?", 10000); }
I will take a look. From the exception I can say that the issue happens because the uwp implementation of the Snackbar is not found. The code is executed from the NetStandard
Looks like a problem with the target versions on UWP and the wrong DLL being included when the developer targets the wrong UWP version?
@TomReemer what version are you targeting? Could you try playing with that setting and see if that changes something?
At least I expect to see "Anchor Not Supported on UWP"
@jfversluis Maybe, but another interesting thing is that this happens when installed via nuget. If I run the sample in XCT repo, it works. Maybe some kind of dll issue.
Hi @ninaada UWP: 18362
can you please play with target versions? (try to set the most recent and test if it works)
for some reason, the Border (https://github.com/xamarin/Xamarin.Forms/blob/b85c28e530eff581c6fa48742e07cd84cca7dd3e/Xamarin.Forms.Platform.UAP/PageControlStyle.xaml#L48) is not found and we are not able to put the Snackbar
FindVisualChildByName<Border>(data, "BottomCommandBarArea")
returns null
@AndreiMisiukevich Tried with 17763 and 19041 as well. Cleaned, uninstalled the app before running. Same issue there also.
I found the solution, you have to change in App.xaml.cs -> MainPage = new NavigationPage(new MainPage());
@VladislavAntonyuk Tried that, still getting the same exception.
To summarize: To make it work right now you need 2 things:
MainPage = new NavigationPage(new MainPage())
. Probably needs to be added to the documentation.Any update on this ?
Just occured to me as well. @VladislavAntonyuk I wanted to try out your workaround but I am a but confused. Into which App.xaml.cs is it supposed to go? In my prism template this is how the first view is called NavigationService.NavigateAsync("NavigationPage/LoginPage");
which supposedly wraps it in navigation page by itself yet I still get the error.
Just occured to me as well. @VladislavAntonyuk I wanted to try out your workaround but I am a but confused. Into which App.xaml.cs is it supposed to go? In my prism template this is how the first view is called
NavigationService.NavigateAsync("NavigationPage/LoginPage");
which supposedly wraps it in navigation page by itself yet I still get the error.
It have to be in shared project App.Xaml.cc. Did you remove the nuget package and added the reference to the source code? If you still see the issue, it means that the container for the Snackbar is not found. Could you please share the sample?
@VladislavAntonyuk Here is a copy of my project. I barely started so there is no confidential information or proprietary code yet. archived.zip
@Luk164 if you do what I wrote above, it will work:
So
you have to set min version to 19041
Make sure you use NavigationPage
Description
Toast and Snackbar are not working in UWP. But, they seem to be working only in the samples repo/app of the toolkit. Attaching a repro of the same.
Steps to Reproduce
Use the zip to download and run the project in Visual Studio
Expected Behavior
Toast should be displayed after 3 seconds with message "Test notification"
Actual Behavior
A System.PlatformNotSupportedException is thrown with message "Operation is not supported in this platform"
Basic Information
Platform Target Frameworks:
Workaround
No known workaround yet
Reproduction Link
TestApp.zip