Click here to Skip to main content
15,913,610 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hai,

i am Using the RibbonWindow.. in that first section i am using ribbonBar buttons and others and in second section i used DockPanel to Show / Load the Other Controls...for respected actions...

i have Two userControls, one is to Display the Details using TextBox and DropDown Controls and Another userControl is to Show all the Existing Data in DataGrid..

these two controls have to be palced in that DockPanel based on Condition, which is in RibbonWindow...

Now,What i want here is, When i click on the any of the Grid row, i need to fill that selected GridRow Data into the Display userControl (userControl1) and that userControl have to load (replace the second userControl) into that DockPanel...

for that what i have Done is....

First i loaded the UserControl2 in to Dockpanel of the RibbonWindow..and fill the Grid Data...

and i have taken the Values of the Grid Row using the ClickEvent --

and in that Method i have called One DelegateEvent to call the Method declared in MainRibbonWindow...

that method is like..below to clear the Dockpanel and load another userControl...

the below method is in MainRibbonWindow...

C#
public void fnDisplayEmployeeDetails(string str,DockPanel dockPannel)

        {

//  dockPannel is to be cleared...

 this.Dispatcher.BeginInvoke((Action)delegate { dockPannel.Children.Clear(); }, null);  //To Clear the Dock Panel

            CtlAddEmployee frm2 = new CtlAddEmployee(str); //userControl1 and here str is Id of the Row...
            
           dockPannel.Children.Add(frm2);

}

Here all the Work is Done well but the DockPanel Remains with the second userControl only(i.e Displaying Grid only..)..The dockpanel not replaced with the fristUserControl...

But if iam trying to dispaly those same values in Another FormWindow Dockpanel..it displaying well ...i don't know why for this strange behaviour...
C#
public void fnDisplayEmployeeDetails(string str,DockPanel docPannel)

        {


               this.Dispatcher.BeginInvoke((Action)delegate { docPannel.Children.Clear(); }, null);  //To Clear the Dock Panel

            CtlAddEmployee frm2 = new CtlAddEmployee(str);
            MainWindow mnWindow = new MainWindow();    //another window Form...
            mnWindow.MainWindowDock.Children.Add(frm2);
            mnWindow.ShowDialog();                                           //here it is showing well....
}

please tell me the correct way to show the Details.. of the Grid values in to another usercontrol..and that usercontrol has to be filled in same Dockpanel....

Thank you
Posted
Updated 2-Jul-12 0:14am
v2

C#
yourdockpanel.Children.Clear()


clears all childrens of dockpanel.
 
Share this answer
 
Comments
V G S Naidu A 2-Jul-12 6:47am    
Thank you for your replay...
i have already wrote that line --> docPannel.Children.Clear();
but i didn't work ...
i need to refer the old object reference of the class by passing it(using parametrized constructors)..not by creating new one and calling them...
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900