TelerikForm.Init()

5 posts, 0 answers
  1. roy
    roy avatar
    8 posts
    Member since:
    Mar 2011

    Posted 31 Aug Link to this post

    Hello

    I am trying to run a very basic App. I simply created a blank Xamarin.Forms app. Then followed the simple steps to add a Telerik Xamarin DataForm.

    But when the app reaches this line in the iOS appdelegate file: "return base.FinishedLaunching(app, options);" it says TelerikForms.init must be called after Forms.Init. I add that line but yet i still get the same error.

    If i comment out the dataform control in the Main.xaml file the app loads and shows "hellow world".

    Any ideas anyone? this is very frustrating to be stuck on the first step.

    Everything is the latest version freshly installed (and reinstalled).

    Help please! Thanks

    Roy

     

  2. roy
    roy avatar
    8 posts
    Member since:
    Mar 2011

    Posted 31 Aug in reply to roy Link to this post

    is there anywhere else other than here : 

    https://github.com/telerik/xamarin-sdk

    where you can find complete code samples??

  3. DevCraft banner
  4. Lance | Tech Support Engineer, Sr.
    Admin
    Lance | Tech Support Engineer, Sr. avatar
    138 posts

    Posted 31 Aug Link to this post

    Hi Roy,

    Thank you for informing us about the missing section on the DataForm's GettingStarted page.  I have awarded you Telerik Points for this discovery.

    The documentation gets updated every Tuesday, so to answer your question directly, you want to add the TelerikForms.Init() method on the AppDelegate.cs file's FinishedLaunching method.

    Here's an example:

    public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {
        global::Xamarin.Forms.Forms.Init();
        Telerik.XamarinForms.Common.iOS.TelerikForms.Init();
        LoadApplication(new App());
     
        return base.FinishedLaunching(app, options);
    }


    In the future, when starting a new project, you can use our Project Wizard to create all the required files, reference the required libraries, and add the the required Init() calls. This gives you a big head start when creating a Telerik-powered Xamarin Forms application.

    thank you for contacting Support and for choosing Telerik by Progress.

    Regards,
    Lance | Tech Support Engineer, Sr.
    Telerik by Progress
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  5. Lance | Tech Support Engineer, Sr.
    Admin
    Lance | Tech Support Engineer, Sr. avatar
    138 posts

    Posted 31 Aug Link to this post

    Hello Roy,

    I wanted to quickly follow-up with you to make sure you're also aware of the requirement to "new-up" the renderers before making the Init() calls.

    Here is the order that is needed to properly initialize the platform specific application, this is true for most custom renderers.

    1- Make sure an ExportRendererAttribute is defined for each renderer you're using. (see example below where I use a DataForm and Calendar)
    2- You need to new-up the renderer so that it is not optimized out during compilation. this is done before Init calls
    3- Call Xamarin.Forms.Forms.Init()
    4- Lastly, call TelerikForms.Init()

    Here is the completed code snippet highlighting those steps:

    // Step 1
    [assembly: Xamarin.Forms.ExportRenderer(typeof(Telerik.XamarinForms.Input.RadCalendar), typeof(Telerik.XamarinForms.InputRenderer.iOS.CalendarRenderer))]
    [assembly: Xamarin.Forms.ExportRenderer(typeof(Telerik.XamarinForms.Input.RadDataForm), typeof(Telerik.XamarinForms.InputRenderer.iOS.DataFormRenderer))]
    namespace YOUR.APP.NAMSPACE.IOS
    {
        [Register("AppDelegate")]
        public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
        {
            public override bool FinishedLaunching(UIApplication app, NSDictionary options)
            {
    // Step 2
                new Telerik.XamarinForms.InputRenderer.iOS.CalendarRenderer();
                new Telerik.XamarinForms.InputRenderer.iOS.DataFormRenderer();
     
    //Step 3
                global::Xamarin.Forms.Forms.Init();
     
    //Step 4
                Telerik.XamarinForms.Common.iOS.TelerikForms.Init();
     
                LoadApplication(new Portable.App());
     
                return base.FinishedLaunching(app, options);
            }
     
    ...
    }


    Let us know if you have any further questions.

    Regards,
    Lance | Tech Support Engineer, Sr.
    Telerik by Progress
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. roy
    roy avatar
    8 posts
    Member since:
    Mar 2011

    Posted 01 Sep in reply to Lance | Tech Support Engineer, Sr. Link to this post

    Hi

    Thanks for the reply. 

    Step 2 is what was missing. It is also not included in your getting started page. Cost me some hours even though in retrospective is quite obvious ;)

Back to Top
DevCraft banner