please be patience to read this... briefly what i want is " when i click on the DataGrid row those values have to be displayed in another form(here userControl).."
I am using one Wpf Ribbon window.. And that window is divided in to two rows. In first row i filled with Wpf Ribbon and in Second row i filled one Dock panel to fill the Usercontrols based on the Action..
The Ribbon Has Two Button
- Display All employees
- To Add Employee
I created two Usercontrol Forms one is to enter the employee Details , second one is to Display all the Records in DataGrid..
Now i First Click on Ribbon Button1 to Display all the Employee Details ,then userControl "CtlGridDisplay "is loaded in to the DockPanel(which is in Ribbon Window) and displaying the all the Details in DataGrid.
Now i Double Click on row and take the selected row employeeId And then i wish to Display that Details in Another Usercontrol "CtlAddEmployee" And this userControl has to be Displayed in that DockPanel only.. for that i trying to Clear the Dockpanel and created the object for the Control "CtlAddEmployee" and added that control to the DockPanel.. But the DockPanel Remains fill with DataGRid only i.e filled with "CtlGridDisplay" ... i can't understand why...
To do this i have also used the Events and Delegates ,it executes all the code well but the Dockpanel is not cleared and didn't loaded with new control..
But when i click one ribbon button1 it loads the "CtlGridDisplay" and when i click on Ribbon button2, its loading "CtlAddEmployee" in Dock panel well...
but when i trying to display the Data what i have click on DataGrid in one userControl to display in Another control doesn't Work..
Events Delegate approach Code is like below...
In User Control "CtlDisplayEmployeeList " the Code is
public event MyOrganizationDetails.MainRibbonWinodw.DisplayEmployeeHandler DisplayemployeeEvent;
private void GridList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
MainRibbonWinodw mainRibbonobj = new MainRibbonWinodw();
this.DisplayemployeeEvent += new MainRibbonWinodw.DisplayEmployeeHandler(mainRibbonobj.fnDisplayEmployeeDetails);
if (GridList.SelectionUnit == DataGridSelectionUnit.FullRow)
{
if (GridList.SelectedItems.Count > 0)
{
for (int i = 0; i < GridList.SelectedItems.Count; i++)
{
DataGrid dg = sender as DataGrid;
EmployeeDetail detail = dg.SelectedItem as EmployeeDetail;
string selectedEmp = detail.EmpId; //it gives Employee Id
if (DisplayemployeeEvent != null)
DisplayemployeeEvent(selectedEmp);
}
}
}
}
In Ribbon Window.. the Code will be... which handles the Event here...
public partial class MainRibbonWinodw : RibbonWindow
{
public delegate void DisplayEmployeeHandler(string str);
public void fnDisplayEmployeeDetails(string str)
{
CtlAddEmployee frm2 = new CtlAddEmployee(str);
DockPanelInRibbon.Children.Clear();
DockPanelInRibbon.Children.Add(frm2);
}
}
In another User Control..
Constructor...
public CtlAddEmployee(string str)
{
InitializeComponent();
fnDisplayingEmployee(str);
}
when i debugging all the Code is fired well but "CtlAddEmployee" form is not loaded to DockPanel... the Dock panel remains with that DataGRid... i Don't know why please tell me the solution .....
Thank you for your patience...to read this...