Thursday, November 9, 2017

XAML Compilation

Using the XAML compiler to increase the performance of a Xamarin.Forms app

XAML can be optionally compiled directly into intermediate language (IL) with the XAML compiler (XAMLC).
XAMLC offers a number of a benefits:
It performs compile-time checking of XAML, notifying the user of any errors.
It removes some of the load and instantiation time for XAML elements.


XAMLC is disabled by default to ensure backwards compatibility. It can be enabled at both the assembly and class level by adding the XamlCompilation attribute.

The following code example demonstrates enabling XAMLC at the assembly level:

It helps to reduce the file size of the final assembly by no longer including .xaml files.

The following code example demonstrates enabling XAMLC at the assembly level:
using Xamarin.Forms.Xaml;
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]You can also enable XAMLC at the class level


Tuesday, October 3, 2017

Creating a list of unique random numbers

Creating a list of unique random numbers

public static List<int> GetUniqueRandomNumbers(int iAmountOfRandomNumbers, int iSmallestNumber, int iBiggestNumber)
        {

            //Create a list of numbers from which the routine
            //shall choose the result numbers
            List<int> lstPossibleNumbers = new List<int>();
            for (int i = iSmallestNumber; i <= iBiggestNumber; i++)
            {
           
                    lstPossibleNumbers.Add(i);
            }


            //Create a list, which shall hold the result numbers
            List<int> lstResultList = new List<int>();

            //Initialize a random number generator
            Random objRand = new Random();

            //For-loop which picks each round a unique random number
            for (int i = 0; i < iAmountOfRandomNumbers; i++)
            {
                //Generate random number
                int randomNumber = objRand .Next(1, lstPossibleNumbers.Count) - 1;
                //Use random number as index for the possible number list
                lstResultList.Add(lstPossibleNumbers[randomNumber]);
                //Remove the chosen result number from possible numbers list
                lstPossibleNumbers.RemoveAt(randomNumber);
            }
            return lstResultList;
        }

Friday, May 19, 2017

iTunes Connect Screenshots Sizes for all iOS (iPhone/iPad/Apple Watch) devices

The following resolutions are acceptable to iTunes connect:
  • iPhone 3+4 (3.5 Inch)
    • 640 x 960
  • iPhone 5 (4 Inch)
    • 640 x 1136
  • iPhone 6 (4.7 Inch)
    • 750 x 1334
  • iPhone 6 Plus (5.5 Inch)
    • 1242 x 2208
    • You need the screenshot in this resolution, the phone scales them down to 1080 x 1920
  • iPad (Air and Mini Retina)
    • 1536 x 2048
  • iPad Pro (12.9 Inch)
    • 2048 x 2732
  • Apple Watch
    • 312 x 390 pixels
    • (only one orientation)

Wednesday, May 17, 2017

Issues in Xamarin.iOS - Failed to launch the simulator: Could not find file "/Users/_____/Library/Caches/Xamarin/mtbs/builds/...

Clean Visual Studio solution: which can be dome by t manually by removing every bin/obj folder,
On Mac, remove  everything under /Users/<User Name>/Library/Caches/Xamarin/mtbs/builds

In Mac you have two ways of accessing the Go To Folder function from the Mac OS X desktop and Finder:
From the “Go” menu navigate down to “Go to Folder” ….or better yet…
Hit Command+Shift+G from the OS X desktop or a Finder window

Friday, May 5, 2017

Xamarin Forms OnPlatform samples in Xaml

** To set image width

<Image x:Name ="lstImage" Aspect="AspectFill"   HorizontalOptions="EndAndExpand" Source=  "{Binding IconUrl}">
                 <Image.WidthRequest>
                   <OnPlatform x:TypeArguments="x:Double">
                     <OnPlatform.Android>30</OnPlatform.Android>
                     <OnPlatform.iOS>30</OnPlatform.iOS>
                     <OnPlatform.WinPhone>40</OnPlatform.WinPhone>
                   </OnPlatform >
                 </Image.WidthRequest>
    </Image >

***To set background color
<StackLayout.BackgroundColor> <OnPlatform x:TypeArguments="Color"> <OnPlatform.iOS>#FF0000</OnPlatform.iOS> <OnPlatform.Android>#00FF00</OnPlatform.Android> </OnPlatform> </StackLayout.BackgroundColor>


To set  it from codebehind use:
Device.OnPlatform(..,..,..)

Tuesday, April 18, 2017

Some useful Plugin's for Xamarin

Here goes the link
https://www.nuget.org/profiles/PluginsForXamarin


In case of Settings Plugin for Xamarin and Windows,
Ensure that you install NuGet into PCL and all platform projects and see Helpers/Settings.cs
If you are installing this in a normal project and not using a pcl create a new file called Settings.cs or whatever you want and copy this code in.

to add/retrieve data use following code:
CrossSettings.Current.AddOrUpdateValue<string>("UserNameKey","Matt");
string sName = CrossSettings.Current.GetValueOrDefault<string>("UserNameKey","unknown");

### Important


sqllite-net-pcl plugin
https://www.nuget.org/packages/sqlite-net-pcl/
https://www.nuget.org/packages/Xam.Plugins.Messaging/

Use C# Interactive Window for your coding experiment in Visual Studio

dailydotnettips.com/2016/01/12/use-c-interactive-window-for-your-coding-experiment-in-visual-studio-2015/