Xamarin.Forms non-resize Stack View (iOS)

Recently I’ve created custom grid control to prevent the keyboard from overlapping with other controls. This works quite well as long as you don’t have any stack views inside this custom grid. Because if you do have one inside the control the iOS renderer will add the same margin to any elements inside the stack view as it will add to the keyboard view (custom grid control). This is not only super annoying it also moves all your elements inside the stack view! 🤬
So it’s time to create another custom control! 💪

Creating the custom element

When I first saw the bug I searched and debugged for a while until I found out that the stack view puts the same margin to each of its elements as the custom keyboard view grid does…
So the solution to this problem is a stack view that does not set any margin to its elements or if someone tries to set a margin, resets it.

Create the control

To create a custom stack view element just add a new class and inherit from StackView.

Create the custom iOS renderer

If we’ve created the control we have to create the custom renderer for iOS to stop the resize behaviour.

The only thing we do inside this renderer is to add a new event handler to fire when the control is to be resized. Every time someone tries to resize the stack view the event handler resets the margin of all children.

That’s everything we need to do 😉
Now you can simply replace every stack views inside the keyboard view with this custom control and the controls will not get any strange margin when the keyboard is shown.

25 thoughts on “Xamarin.Forms non-resize Stack View (iOS)

  1. I’m not sure why but this blog is loading very slow for me.

    Is anyone else having this problem or is it a issue
    on my end? I’ll check back later and see if the problem still exists.

  2. What’s up everybody, here every person is sharing these knowledge, therefore
    it’s fastidious to read this blog, and I used to pay a visit
    this website every day.

  3. I like the helpful information you provide in your articles.
    I’ll bookmark your weblog and check again here regularly. I am quite certain I’ll learn lots of new stuff right
    here! Good luck for the next!

  4. I’m extremely impressed along with your writing talents as smartly as
    with the layout in your blog. Is this a paid theme or did you modify it your self?
    Either way keep up the nice high quality writing, it is uncommon to
    see a great blog like this one nowadays..

  5. Hello my loved one! I wish to say that this post is awesome,
    nice written and come with approximately all significant infos.
    I’d like to peer more posts like this .

  6. Wonderful article! That is the type of info that are meant to be shared around
    the internet. Disgrace on Google for now not positioning this publish higher!

    Come on over and seek advice from my website . Thank you =)

  7. Hmm it appears like your site ate my first comment (it was super long) so I guess I’ll just
    sum it up what I wrote and say, I’m thoroughly enjoying
    your blog. I too am an aspiring blog blogger but I’m still new to the whole thing.

    Do you have any suggestions for rookie blog writers? I’d really appreciate
    it.

  8. Normally I don’t learn post on blogs, however I would like to say that this write-up very compelled me to take
    a look at and do so! Your writing taste has been surprised me.
    Thank you, very nice post.

  9. Hello there! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me.
    Anyways, I’m definitely glad I found it and I’ll be book-marking and checking back frequently!

  10. It’s the best time to make a few plans for the long run and it’s
    time to be happy. I have read this post and if
    I may just I desire to recommend you some attention-grabbing things or advice.
    Perhaps you could write subsequent articles regarding this article.
    I wish to learn more issues about it!

  11. Spot on with this write-up, I honestly believe this amazing site needs a lot more attention. I’ll probably be
    back again to see more, thanks for the info!

  12. Simply want to say your article is as amazing.
    The clearness in your post is just nice and i can assume you’re an expert on this subject.
    Well with your permission allow me to grab your RSS feed to
    keep updated with forthcoming post. Thanks a million and please carry on the rewarding work.

  13. I every time used to study post in news papers but now as I am a user
    of web so from now I am using net for posts, thanks to web.

  14. Wow, awesome blog layout! How long have you been blogging for?

    you make blogging look easy. The overall look
    of your website is great, let alone the content!

  15. Hi i am kavin, its my first time to commenting
    anywhere, when i read this article i thought i could also create comment due to this sensible paragraph.

  16. Thanks for finally writing about > Xamarin.Forms non-resize
    Stack View (iOS) / flokri < Liked it!

  17. Hello i am kavin, its my first occasion to commenting anywhere, when i
    read this article i thought i could also make comment due to this good paragraph.

  18. magnificent publish, very informative. I’m wondering why the opposite
    specialists of this sector do not notice this. You must continue your writing.
    I am sure, you’ve a great readers’ base already!

  19. Having read this I believed it was extremely informative.
    I appreciate you spending some time and energy to put this informative article together.
    I once again find myself personally spending way too much time both
    reading and commenting. But so what, it was still
    worthwhile!

  20. I am not sure where you’re getting your information, but great topic.
    I needs to spend some time learning more or understanding more.
    Thanks for great info I was looking for this information for my mission.

  21. Spot on with this write-up, I really feel this website needs far more attention. I’ll probably be back
    again to see more, thanks for the info!

  22. Someone necessarily assist to make critically
    posts I might state. This is the first time I frequented your website
    page and up to now? I amazed with the research you made to make this actual submit
    extraordinary. Excellent process!

  23. Write more, thats all I have to say. Literally,
    it seems as though you relied on the video to make your point.

    You obviously know what youre talking about, why throw away your intelligence on just posting videos to your weblog when you could be giving us something informative to
    read?

  24. Hello, Neat post. There is an issue with your website in web explorer,
    might test this? IE nonetheless is the marketplace chief and
    a huge section of other folks will pass over your
    excellent writing because of this problem.

  25. If you desire to get much from this paragraph then you have to apply these techniques to your won webpage.

Leave a Reply

Your email address will not be published. Required fields are marked *