Problem instantiating prefab panel

I am having a strange problem. I show a panel when a button is clicked in my app. This was working fine when the panel was in the Canvas hierarchy but inactive (until the button was clicked). I decided to make the panel a Prefab and instantiate it as needed.

Here is the code:

GameObject searchPanel = (GameObject) Instantiate(searchPanelPrefab);
searchPanel.transform.SetParent(canvas.transform);

The problem I’m seeing is only the bottom toolbar of the panel is being displayed onscreen. It is displayed at the proper position but the rest of the panel is nowhere to be seen.

If I just drag the prefab into the canvas in the editor, the whole panel is displayed as expected.

I’m fairly new to Unity and was wondering if I’m making some sort of common error. Thoughts?

OK, I figured it out. Apparently you need to call the version of SetParent that takes a second argument (worldPositionStays) and set that false.

searchPanel.transform.SetParent(canvas.transform, false);

It is working fine when I do that.