I want to add my ToolBar inside the ToolBarPanel in codebehind.
I saw one example of Button & Canvas panel.
Here is the code:
Canvas.SetLeft(newButton, containerPoint.X - objectPoint.X);
Canvas.SetTop(newButton, containerPoint.Y - objectPoint.Y);
How can I achive samething with ToolBar & ToolBarPanelinstead of using Canvas & Button?
The code you gave is not adding the button to canvas, it sets extension properties that specify coordinates the button will be located at, if it is placed on
Canvaspanel.ToolBarPanelis a primitive panel used byToolBarto arrange its items. Unless you want to customize behavior you should be just usingToolBaroptionally placing it intoToolBarTray.ToolBaris anItemsControl(just likeListBoxfor example), so to add a button from code, add it to panel’sItemscollection: