Thursday, August 29, 2019

Trying to ouput in pdf what i have in listview

This is what i have in listview from post.cs

It is making me a new list
What i want in PDF



Tuesday, July 30, 2019

Setting time format

https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings


if you want a constantly updating time, use a Timer
System.Timers.Timer timer = new System.Timers.Timer(1000);
timer.Elapsed += TimerElapsed;
timer.AutoReset = true;
timer.Start();

private void TimerElapsed(Object source, ElapsedEventArgs e)
{
    myLabel.Text = e.SignalTime.ToString();
}
if you want to use databinding, have your elapsed event update the ViewModel property that your label is bound to instead of directly updating the Label

  • If you type string currentDate = DateTime.Now.ToString()

Friday, May 24, 2019

If Previewer not showing

Right click on .Android solution- Options-Androidapplication-then make sure minimum target coincides with SDK manager installed under Tools.

Tuesday, May 7, 2019

How to add and use photos in Xamarin forms


  1. On the main Xamarin project. Right click-add folder-name it. Put your photos in there.
  2. Right click on photo - select Build Action - Then Embedded Resource.
  3. Add photo into IOS and Android projects ---
  4. Right click on photo and select Copy.


Adding the photo into IOS and Android
so the photo will show up on IOS and Android OS

  1. Go to IOS/Android Project.
  2. Scroll to Resources. Right click on Resources.(on Android inside Resources-right click drawable)
  3. Click paste. (On IOS, right click image-Select BundleResource)
In Xaml file
  • <Image Source="" x:Name="MyImage"/>  //MyImage is name to access it from c#
In C# file
  •  MyImage.Source = ImageSource.FromFile("logo.jpg");  //logo.jpg is name of file

Monday, May 6, 2019

How to store user settings? Using xam.plugins.setting - Xamarin forms

Using a plugin from Nuget


  1. Right click on your project-click add Nuget Packages.  Type xam.plugins.setting on search. Click on it and Add package.
  2. Add it on your Android project files and IOS project files perform step 1.
  3. Make a folder called Helpers(or any folder name you want some uses Util- on the solution project then -  Create a new file called Settings.cs (empty class file)
  4. Copy and paste from readme.txt 
// Helpers/Settings.cs
using Plugin.Settings;
using Plugin.Settings.Abstractions;

//$rootnamespace$ is the name of your project followed by where the file is stored
// in this case it's in Helpers folder namespace $rootnamespace$.Helpers
{
  /// <summary>
  /// This is the Settings static class that can be used in your Core solution or in any
  /// of your client applications. All settings are laid out the same exact way with getters
  /// and setters. 
  /// </summary>

  public static class Settings
  {
    private static ISettings AppSettings
    {
      get
      {
        return CrossSettings.Current;
      }
    }

    #region Setting Constants

//variable naming
//"SettingsKey" is always a string that is a unique ID that will be stored in the device to //access constructor GeneralSettings name it something the describes what you are storing
ie. NameKey, EmailKey;  "name_key", "email_key"
    private const string SettingsKey = "settings_key";
    private static readonly string SettingsDefault = string.Empty;

    #endregion


//contructor to get and set the Settings to be stored. Name the constructor 
something the describes what you are storing. It will be called on the Page where you want to use it.

//ie NameSettings, EmailSettings     public static string GeneralSettings
    {
      get
      {
//SettingsKey is the string from the const unique name variable above
        return AppSettings.GetValueOrDefault(SettingsKey, SettingsDefault);
      }
      set
      {
        AppSettings.AddOrUpdateValue(SettingsKey, value);
      }
    }

  }
}

Now to use the Settings.cs -  you need include that namespace in the file where you want to use it. ie
//need to use namespace from where settings were SET to access it and use it to store user input.  roosspace is name of your project.
using $rootnamespace$.Helpers;


To save it: use the syntax below to save the data in Save button c file.
Use Settings is the file name where the code behind of get and sets.
Drain1LocationSettings is the GeneralSettings
EntryorPicker is in xaml file where the user enters the data needs to be save.
Settings.GeneralSettings = EntryorPicker;

To display the saved data: go to page or file where you want the saved data to be displayed then enter format syntax below
Labelofsavedata.Text = Settings.GeneralSettings;



https://www.youtube.com/watch?v=7DFCMm_4Nro


To clear IOS emulator settings:
delete app from emulator, clean all, then re run app.


http://bsubramanyamraju.blogspot.com/2018/04/appsettings-how-to-store-user-settings.html