Automatically resizing Windows Mobile Forms when the SIP is shown

This was bugging me for awhile, but it took me until now to get around to fixing it.

I had an issue with forms with text boxes near the bottom, and when the SIP (on-screen keyboard) is shown, then it completely hides the textbox.   So I went googling and found this:

Manage soft input panel (SIP)

And with that knowledge, wrote a quick util method to automatically add this behavior:

public static void AddAutoInputPanelResizing (Control parent, IContainer iContainer)
	var p = new Panel
		Height = 0,
		Visible = false,
		Name = "SIP Placeholder",
		Dock = DockStyle.Bottom,
	parent.Controls.Add (p);
	p.SendToBack ();

	var ip = new InputPanel (iContainer);
	ip.EnabledChanged +=
		(sender, e) =>
			parent.SuspendLayout ();
			p.Visible = ip.Enabled;
			p.Height = ip.Bounds.Height;
			parent.ResumeLayout ();

Leave a Reply