How to clone a TPanel in Delphi FMX application?


I am building a application using FMX. This app will run on Windows, Mac OSX, and Linux.
I have a need to clone a TPanel which is contained in another TPanel.
Clone function provided in FMX is throwing an error:

Class TForm1 not found.

How to clone a TPanel in an FMX app?
Here is the code I am using:
procedure TForm1.Button1Click(Sender: TObject);
CurrentControl, ClonedControl: TFMXObject;
CtlrNameCnt: String;
CtlrNameCnt := IntToStr(Panel1.ControlsCount);

CurrentControl := Panel1;

ClonedControl := Clone(CurrentControl); //<- this gives error := + ‘_’ + CtlrNameCnt;
ClonedControl.Parent := Panel1;

Comments are closed.