This is a migrated thread and some comments may be shown as answers.

Customize the title bar of a DockPanel

3 Answers 154 Views
Dock
This is a migrated thread and some comments may be shown as answers.
kdev
Top achievements
Rank 1
kdev asked on 14 Aug 2007, 01:14 PM
Hi,

I create a custom DockPanel and I want to override the menu shown when we click the DropDownButton.
is that possible?
if not, can we add a second DropDownButton to the title bar of the DockPanel ?
Or is there a way to customize this title bar ? 

Thanks,
Kort

3 Answers, 1 is accepted

Sort by
0
Jordan
Telerik team
answered on 15 Aug 2007, 11:20 AM
Hi kort,

You can change the dropdown menu as follows:
 
private void ChangeDropDownMenu(DockPanel dockPanel)  
        {  
            if (dockPanel.DefaultPresenter != null && dockPanel.DefaultPresenter is DockPresenterControl)  
            {  
                RadItem dockPresenterElement = ((DockPresenterControl)dockPanel.DefaultPresenter).DockPresenterElement;  
                ClassSelector selector = new ClassSelector("DockPresenterCaptionDropDown");  
                RadDropDownButtonElement dropDownButton = selector.GetSelectedElements(dockPresenterElement)[0] as RadDropDownButtonElement;  
                this.AddMenuItems(dropDownButton);  
            }  
        }  
 
        private void AddMenuItems(RadDropDownButtonElement dropDownButton)  
        {  
            dropDownButton.Items.Clear();  
 
            RadMenuItem menuItem = new RadMenuItem();  
            menuItem.Text = "Some Text";  
            dropDownButton.Items.Add(menuItem);  
 
            menuItem.Click += new EventHandler(menuItem_Click);  
        }  
 
        void menuItem_Click(object sender, EventArgs e)  
        {  
            MessageBox.Show("Menu item was clicked.");  
        } 

It is important that you call the ChangeDropDownMenu method after a call to SetDock:
 
this.dockingManager1.SetDock(dockPanel, dockPosition);  
 
this.ChangeDropDownMenu(dockPanel); 

Hope that helps.

 
Sincerely yours,
Jordan
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
kdev
Top achievements
Rank 1
answered on 28 Aug 2007, 04:40 PM
Hi Jordan,

it works fine, thanks

But when I change the DockPanel dock state (Drag&Drop it), I got the original menu. perhaps that we call the SetDock method. So I try to call ChangeDropDownMenu in the Dockpanel.Activated event but it works only if we select an other panel before. I try also with the Dockingmanager.DockingStateChanged event without success :(

In which Docking event, have I to call the ChangeDropDownMenu?

Regards  
Kort
0
Julian Benkov
Telerik team
answered on 29 Aug 2007, 04:55 PM
Hi Kort, 

You can use this code snippet:

(dockingManager1.PrimarySite as DockSite).PostLayout +=new EventHandler(Form1_PostLayout);  
 
void Form1_PostLayout(object sender, EventArgs e)  
{  
   ChangeDropDownMenu(dockPanel1);  


Kind regards,
Julian Benkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Dock
Asked by
kdev
Top achievements
Rank 1
Answers by
Jordan
Telerik team
kdev
Top achievements
Rank 1
Julian Benkov
Telerik team
Share this question
or