Xamarin Blog by officialdoniald
108 FOLLOWERS
Introducing Xamarin and solving bigger problems. In this blog, you will find the latest xamarin articles.
Xamarin Blog by officialdoniald
3y ago
Download this Package to your .NET Standard Library: https://www.nuget.org/packages/Xam.Plugins.Settings/
If you don’t downloaded the Newtonsoft.Json Package yet, please add this package too.
After the installations, we can save and read any object in your application:
Save:
Plugin.Settings.CrossSettings.Current.AddOrUpdateValue("CurrentTask", JsonConvert.SerializeObject(yourobject));
Read:
var objectInJSON = Plugin.Settings.CrossSettings.Current.GetValueOrDefault("CurrentTask", "");
JsonConvert.DeserializeObject<yourobject>(objectInJSON)
Hints: If you get some error during de serial ..read more
Xamarin Blog by officialdoniald
3y ago
https://github.com/officialdoniald/Xamarin.MQTT
NuGet Gallery | Xamarin.MQTT 1.0.0
Usage:
I created two contructors of the MQTTConnection class. You can init this object with a specific MqttClientOptions and a string array of your topics, or with username, passowrd, a string array of your topics, servername, port and clientid.
https://github.com/officialdoniald/Xamarin.MQTT/blob/master/Xamarin.MQTT.Example/Xamarin.MQTT.Example/App.xaml.cs
I created in the App.cs a static variable of the MQTTConnection class, so I can reach this object anywhere.
You have to connect to the MQTT server:
await ..read more
Xamarin Blog by officialdoniald
3y ago
Xamarin.Forms.Save.Open.PDF/README.md at master · officialdoniald/Xamarin.Forms.Save.Open.PDF (github.com)
NuGet Package: https://www.nuget.org/packages/Xamarin.Forms.SaveOpenPDFPackage/
Download this Package just in your Standard Library.
Platform specific things:
Android:
In the AndroidManifest.xml file, you have to add theese lines:
https://github.com/officialdoniald/Xamarin.Forms.Save.Open.PDF/blob/master/Xamarin.Forms.Save.Open.PDF/Xamarin.Forms.Save.Open.PDF.Android/Properties/AndroidManifest.xml
Create, if you don’t create yet, an “xml” folder into the “Resources” folder in the A ..read more
Xamarin Blog by officialdoniald
3y ago
officialdoniald/Xamarin.Forms.DynamicSize (github.com)
NuGet Package: NuGet Gallery | Xamarin.Forms.DynamicSize 1.0.0
What and when should this package be used? If you’re making a design plan and you only made it to one size and you gave everything a fixed size, so this little package is for you. This can dynamically increase the size no matter what resolution device you are running on. You don’t have to worry that it will look different on every display, it will look the same on each one.
Create some design for example in Figma.
You need to call the Init function of the DynamicSizeCalculator ..read more
Xamarin Blog by officialdoniald
3y ago
officialdoniald/Xamarin.Forms.MVVM
This Package implement the https://docs.microsoft.com/en-us/xamarin/xamarin-forms/enterprise-application-patterns/dependency-injection TinyIoC Container. => You can use DI in your code.
Naming convention is very important!!!
MVVM: You have to create the common folders: Model, View and ViewModel.
Model: Not nessessary to create this folder, but the nice thing would be to make a separate folder for UI models. If you want to Bind a model’s Property, you have to derive your model class from ExtendedBindableObject.
public class Profil : ExtendedBinda ..read more
Xamarin Blog by officialdoniald
3y ago
Suppose we use an Activity and swap Fragments within the Activity.
Within Acitvity, use RelativeLayout for External Layout and we will place it at the bottom, centering our menu.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f5f5f5">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:layout_alignParentBotto ..read more
Xamarin Blog by officialdoniald
3y ago
Android don’t have rounded corner property, so we have to define a shape in an xml and we have to set this xml as a background of a View.
Let’s define our rounded corner in the Resource/drawable folder: rounded.xml. If we want a different radius or different color, just change the android:radius or android:color property.
<?xml version="1.0" encoding="utf-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle"
android:alpha="0.2">
<solid android:color="#F4F4F7"/>
<corner ..read more
Xamarin Blog by officialdoniald
3y ago
In Android you can’t set shadow property of an element except Button and TextView. So we have to define a shape in an xml and set is as background of an element.
Let’s create our first shadow background! Create a shadow.xml file in the Resource/drawable folder, and paste this code in the file.
<?xml version="1.0" encoding="utf-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle"
android:alpha="0.2">
<solid android:color="#F4F4F7"/>
<corners android:radius="11dp"/> ..read more
Xamarin Blog by officialdoniald
3y ago
We all use usually grids in our apps. But it doesn’t matter how it appears. Here now it’s not going to be about having a grid and exposing it to a page and just going to be there, but there’s more of everything on a page and you don’t want to have a certain height and be able to scroll through a small area but be as high as there are elements in it.
First step: create a Xamarin.Android Project.
Instead of the ListView, we have to impleemnt a custom GridView: ExpandableHeightGridView. I created a Components folder in my project and in this filder I created this implementation:
using System;
us ..read more
Xamarin Blog by officialdoniald
3y ago
We all use lists in our apps. But it doesn’t matter how it appears. Here now it’s not going to be about having a list and exposing it to a page and just going to be there, but there’s more of everything on a page and you don’t want to have a certain height and be able to scroll through a small area but be as high as there are elements in it.
First step: create a Xamarin.Android Project.
Add a ListView to your layout’s xml:
<ListView
android:id="@+id/someListView"
android:layout_width="match_parent"
android:layout_height="wrap_conte ..read more