Xamarin.Forms | useful Xamarin Projects that can be applied to a real world | Form library
kandi X-RAY | Xamarin.Forms Summary
kandi X-RAY | Xamarin.Forms Summary
useful Xamarin Projects that can be applied to a real world application.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Xamarin.Forms
Xamarin.Forms Key Features
Xamarin.Forms Examples and Code Snippets
Community Discussions
Trending Discussions on Xamarin.Forms
QUESTION
I have a hard time understanding the difference between those 3 things when creating a project using Xamarin.Forms or MAUI. I know what these are - INotifyPropertyChanged
is an interface you need to implement when you want to use bindings in XAML, BindableObject
is Xamarin.Forms class that implements said interface and ObservableObject
is a class found in Xamarin Community Toolkit that also implements that interface. I just don't really understand the differences between them (especially the latter two) and when you would use any of them? I have read different tutorials and they all say different things - that you need to implement the interface yourself (so your viewmodel implements it), that your viewmodel needs to inherit from BindableObject
, or - if you're using Xamarin Community Toolkit (which you probably should use/are using) - inherit from ObservableObject
. But - like I said - why should you use any of the solutions mentioned above over the others?
If you implement INotifyPropertyChanged
interface Visual Studio (or ReSharper extension, I'm not sure which one) automatically implements the method it needs to and adds this code:
ANSWER
Answered 2022-Feb-23 at 12:53There is some confusion I think about the different classes:
Xamarin.Forms.BindableObject is meant to be used to create something like a custom view with bindable properties. It also implements INotifyPropertyChanged, but I don't think you should use it for a ViewModel.
The ObservableObject from the community toolkit can be used as a base class for any class you like to use with data binding, you don't need to implement it yourself.
If you have some custom requirements for handling the OnPropertyChanged, you do need to implement the interface yourself, but if you just want to have default behaviour, ObservableObject is perfectly fine.
QUESTION
I'm using
...ANSWER
Answered 2022-Jan-27 at 07:39First, you can try to add SKStoreReviewController.RequestReview(Window.WindowScene)
in the FinishedLaunching method of your xxx.ios->AppDelegate.cs; start the project to see if it is correct.
If the above method goes wrong, using DependencyService is the right way to go.
Here is the interface code:
QUESTION
We have Xamarin.Forms solution with iOS and UWP projects. We use Azure pipelines to build the iOS project. Until yesterday everything was working fine. Now the build fails at the NuGet Restore step with the error:
##[error]The nuget command failed with exit code(1) and error(/Users/runner/work/1/s/"MyProjectName.UWP".csproj : error MSB4057: The target "_IsProjectRestoreSupported" does not exist in the project.
We can see that the problem occurs when trying to restore NuGet packages for the UWP project on the Mac OS build host. Image: macOS-11
Workaround will be to exclude it from the solution, but we are using it for testing purposes and this is not a good option for us.
...ANSWER
Answered 2022-Jan-26 at 09:39- Updated Answer This can be resolved using MSBuild task instead, as the collogues mentioned below. However, in my case this still lead to the same error. After investigating the pipeline. The root cause has been identified: Both in MSBuild@1 and XamariniOS@2 tasks you should target the specific iOS Project and not the solution file, like so:
" - task: MSBuild@1 inputs: solution: 'PathToIosProject/myproject.iOS.csproj' configuration: '$(BuildConfiguration)' msbuildArguments: /t:restore
" - task: XamariniOS@2 inputs: solutionFile: PathToIosProject/myproject.iOS.csproj' configuration: '$(BuildConfiguration)' packageApp: true signingIdentity: $(APPLE_CERTIFICATE_SIGNING_IDENTITY)
- Old Answer
We have managed to resolve the issue. The root cause of it seems to be an update to the mono framework in the MacOS pipeline build agent. In order to fix it, we need a script for downloading and installing an older version of the mono framework as a first step of the build pipeline like so: link to the pipeline tasks photo
This is the code of the bash scrip used in the task:
#!/bin/bash set -ex
MONO_MACOS_PKG_DOWNLOAD_URL='https://download.mono-project.com/archive/6.12.0/macos-10-universal/MonoFramework-MDK-6.12.0.100.macos10.xamarin.universal.pkg'
mkdir -p /tmp/mono-install cd /tmp/mono-install
mono --version
wget -q -O ./mono-installer.pkg "$MONO_MACOS_PKG_DOWNLOAD_URL"
sudo installer -pkg ./mono-installer.pkg -target /
mono --version
ls -alh /Library/Frameworks/Mono.framework/Versions/Current
QUESTION
I use Lazy initialization for app singleton in Xamarin.Forms (app runs on iOS):
...ANSWER
Answered 2022-Jan-04 at 20:57In this case, there can be race-condition.
If two (or more threads) simultaneously reads Instance
for first time, there will be created multiple instances of DataSingleton
. However every other read will get just one instance. It depends on your scenario, if it is ok.
QUESTION
I have a problem with making a game using Xamarin.Forms and MVVM.
In the game there's a submarine which is controlled by the user and there are mines falling down so the user has to avoid these mines. The mines are generated in runtime using 2 timers, so I represent these with a CollectionView in XAML.
I already made this game using WPF (and also using WinForms) and in that case I used Canvas for the game area (ItemsControl for the mines) and the bindings works well. Now (using Xamarin.Forms) I tried implementing the game area with AbsoluteLayout and with RelativeLayout, but always received eg. the following output (RelativeLayout):
[0:] Binding: '160' cannot be converted to type 'Xamarin.Forms.Constraint'
The current XAML code:
...ANSWER
Answered 2021-Dec-30 at 00:57From the error:
[0:] Binding: '160' cannot be converted to type 'Xamarin.Forms.Constraint'
You can see that it can't convert the integer to the type Constraint
that is expected by the binding expression.
When you do this:
QUESTION
I get the following Error message after migrating from FormsApplicationActivity to FormsAppCompatActivity:
Android.Views.InflateException: 'Binary XML file line #31 in com.myapp.app:layout/mtrl_calendar_month_labeled: Binary XML file line #18 in com.myapp.app:layout/mtrl_calendar_month: Error inflating class com.google.android.material.datepicker.MaterialCalendarGridView'
The error happens in the OnCreate at the first line base.OnCreate(savedInstanceState);
My mainactivity looks like this
...ANSWER
Answered 2021-Dec-17 at 21:30I was able to fix the exception, but now my toolbar is completely gone and I created a new stackoverflow post for that problem: Xamarin Forms Android Toolbar missing after migration to Flyout and AppCompat
The solution for this problem here was to delete the layout.xml
file and to use the following values in the styles.xml
file:
QUESTION
Using Xamarin.Forms to built Android app. Phone Honor 30i. Android 10. Build version 3.1.0.140(C10E1R3P2). After updating on this build(dont remember version of previously installed build) my app throw exception in log and crash at once after launch. this is from log:
...ANSWER
Answered 2021-Dec-01 at 02:59Thank you for providing the information regarding this issue, we have reported it to the R&D team. at the same time, we have provided a workaround, you can downgrade the Account SDK version to 5.0.3.302
, which should solve your problem.
QUESTION
After upgrade my Xamarin.Forms version to 5.0.0.2244, I'm getting the following warning in Main.cs
file inside my iOS project:
ANSWER
Answered 2021-Nov-17 at 20:38Class reference through a string is now deprecated. You need to change this line:
QUESTION
First of all, I know the documentation states that I should set the MainPage
property in the App
class constructor (https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/application-class#mainpage-property).
To simplify, what I need to do is some async operation in the OnStart() event handler and after that, set the MainPage property. This question wants to get to the root issue in the framework itself.
Something like this (simplified on a blank Xamarin.Forms project, you can try if you want):
...ANSWER
Answered 2021-Nov-12 at 13:08As you can see, OnStart
returns void, not Task
, so it's not intended to be asynchronous. You made it async void
but caller (framework code which calls OnStart) has no means to wait for that async operation to complete. For caller, OnStart
completes right when await Task.Delay
hits (that's when OnStart
returns), and so it continues to other stuff. When await Task.Delay
completes and you set MainPage
- you are not actually in OnStart
stage of initialization process, that stage has already been completed 100 milliseconds ago.
Consider this example which should clarify it:
QUESTION
I am trying to bind the "SelectedItems" property of my CollectionView between my View and my ViewModel. But the TwoWay didnt work.
I can send information to my View, but i cant send information to my ViewModel.
( all another biding works correctly )
Some code,in my ViewModel :
...ANSWER
Answered 2021-Nov-07 at 05:14Two changes needed:
The type of the bound property (
SelectedElement
) must match the type of the CollectionView property (SelectedItems
). XF Doc says the type isIList.
Your bound property (if the correct type) will get set to the SelectedItems list when the binding is resolved (page is loaded; BindingContext set). It starts out as an empty list. As selection changes, the list's contents change. But the list object itself is the same object, so the setter never gets called again.
So how do you see a change? Via either
SelectionChangedCommand
, orSelectionChanged
event.To use
SelectionChangedCommand
:add to CollectionView XAML:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Xamarin.Forms
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page