create event outside the application
-
2012年7月27日 6:26
i have application in vs2010 wpf
i have two window on is BuildingWindow and other is WindowTest, in WindowTest there is datagrid, if click on datagrid ,want to access datagrid data in BuildingWindow , i did in c# ( windows form) as mention below but it not working in wpf
namespace Society_Management
{
public partial class BuildingWindow : Window
{
WindowTest objWindowTest = new WindowTest();
public BuildingWindow()
{
InitializeComponent();
objWindowTest.dataGrid1.MouseDoubleClick += newSystem.Windows.Input.MouseButtonEventHandler(dataGrid1_MouseDoubleClick);
}
private void dataGrid1_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
int i = objWindowTest.dataGrid1.SelectedIndex;
DataRowView v = (DataRowView)objWindowTest.dataGrid1.Items[i]; // this give you access to the row
System.Windows.MessageBox.Show(v[3].ToString());
}}
}
Best Regard Naweez
全部回复
-
2012年7月28日 0:26
i have application in vs2010 wpf
i have two window on is BuildingWindow and other is WindowTest, in WindowTest there is datagrid, if click on datagrid ,want to access datagrid data in BuildingWindow , i did in c# ( windows form) as mention below but it not working in wpf
namespace Society_Management
{
public partial class BuildingWindow : Window
{
WindowTest objWindowTest = new WindowTest();
public BuildingWindow()
{
InitializeComponent();
objWindowTest.dataGrid1.MouseDoubleClick += newSystem.Windows.Input.MouseButtonEventHandler(dataGrid1_MouseDoubleClick);
}
private void dataGrid1_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
int i = objWindowTest.dataGrid1.SelectedIndex;
DataRowView v = (DataRowView)objWindowTest.dataGrid1.Items[i]; // this give you access to the row
System.Windows.MessageBox.Show(v[3].ToString());
}}
}
Best Regard Naweez
i got solution
public partial class BuildingWindow : Window
{WindowTest objWindowTest = new WindowTest();
public BuildingWindow()
{
InitializeComponent();
objWindowTest.dataGrid1.MouseDoubleClick += new System.Windows.Input.MouseButtonEventHandler(dataGrid1_MouseDoubleClick);
EventManager.RegisterClassHandler(typeof(Window), DataGrid.MouseDoubleClickEvent, new MouseButtonEventHandler(dataGrid1_MouseDoubleClick), true);
}
private void dataGrid1_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
string id = objWindowTest.BuildingId}
}
Best Regard Naweez

