How Load Dockpanel from resource dictionary in c#

899 views Asked by At

I want to load a dockpanel control to an wpf window. the dockpanel control is on a resource dictionary file and that is merged in the window I want to use it. I want the c# code that can add this dock panel to a existing dockpanelhost control on the window dynamically upon a button click event. Please help me by providing the c# code implementation

Regards

1

There are 1 answers

1
bartosz.lipinski On BEST ANSWER

You can get your DockPanel from resources like that:

var dockPanel = FindResource("DockPanelKey") as DockPanel;

Later add this line to insert dockPanel to for example grid:

m_Grid.Children.Add(dockPanel);