tags:

views:

46

answers:

1

Hi all,

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 & toolbarpanel instead of using canvas & butoon?

Thanks Ashish

+1  A: 

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 Canvas panel.

ToolBarPanel is a primitive panel used by ToolBar to arrange its items. Unless you want to customize behavior you should be just using ToolBar optionally placing it into ToolBarTray.

ToolBar is an ItemsControl (just like ListBox for example), so to add a button from code, add it to panel's Items collection:

toolbar.Items.Add(newButton);
repka
thnaks for the reply
ashish semwal