Tuesday, September 5, 2017

Injecting a new root element in a Xamarin Forms Content Page

If you want to insert a new root element on a content page (using Xamarin Forms) you must set the Content to null first before assigning it again. Otherwise touch events will not register (at least not on iOS).

For example, add the entire view in an AbsoluteLayout could look like this:

 // Get a reference to the content
 var content = page.Content;
 page.Content = null// This line is key

 // Create a new root element and add the content
 var absoluteLayout = new AbsoluteLayout();
 absoluteLayout.Children.Add(content);

 // Replace the content
 page.Content = absoluteLayout;

I would do this directly after the call to InitializeComponent() in the code behind of the view.


17 comments:

  1. You know your projects stand out of the herd. There is something special about them. It seems to me all of them are really brilliant! online marketing

    ReplyDelete
  2. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site. xamarin training in Chennai

    ReplyDelete
  3. Extraordinary blog. you put Good stuff. All the themes were clarified briefly.Thanks for sharing that post.Keep in blogging…
    No.1 Software Testing Training Institute in Chennai | Best Selenium Training Institute in Chennai | Web Designing Training Institute in Chennai

    ReplyDelete
  4. Great Article… I love to read your articles because your writing style is good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.
    Graphic Design Training Institute in Chennai | Graphic Design Training Institute in Velachery

    ReplyDelete
  5. Thank you for taking the time to provide us with your valuable information.keep sharing your post regularly..
    Certified Ethical Hacking Training in Chennai | Hacking Training in Saidapet

    ReplyDelete
  6. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging…
    Cisco CCNP Certification Exam Center in Chennai | Best CCNP Training in Alandur

    ReplyDelete
  7. Great Article… I love to read your articles because your writing style is good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.
    No.1 Microsoft Azure Training Institute in Chennai | No.1 Microsoft Azure Training Institute in Velachery

    ReplyDelete
  8. Thank you for taking the time to provide us with your valuable information.keep sharing your post regularly..
    Certified Ethical Hacking Training in Chennai | Blue Prism Training Institute in Chennai

    ReplyDelete
  9. Really it was an awesome article...very interesting to read..You have provided an nice article....Thanks for sharing..
    Cloud Computing Training Institute in Chennai | Cloud Computing Training Institute in Velachery

    ReplyDelete
  10. I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.
    xamarin classes
    best xamarin course

    ReplyDelete
  11. Nice blog. Thank you for sharing. The information you shared is very effective for learners I have got some important suggestions from it.
    CLOUD COMPUTING Classes in Chennai | CLOUD COMPUTING Courses in Velachery

    ReplyDelete
  12. These provided information was really so nice, thanks for giving that post and the more skills to develop after refer that post.
    Best Dotnet Training Institute in Chennai|Best Dotnet Training Institute in Velachery

    ReplyDelete
  13. I just found this blog and have high hopes for it to continue. Keep up the great work, its hard to find good ones. I have added to my favorites. Thank You.
    No.1 Automation Anywhere Training Institute in Chennai | No.1 Automation Anywhere Training Institute in Kanchipuram | No.1 Automation Anywhere Training Institute in Velachery

    ReplyDelete
  14. My rather long internet look up has at the end of the day been compensated with pleasant insight to talk about with my family and friends.
    No.1 Blue Prism Training Institute in Chennai | No.1 Blue Prism Training Institute in Velachery | No.1 Blue Prism Training Institute in Kanchipuram

    ReplyDelete