我的父视图中有一个数据网格。
当我在网格中选择一个项目时,
我想打开一个子窗口
并将所选项目值传递给子窗口
我需要根据所选值提交更改。
我正在修改以下代码,即我需要转移到子窗口的点击事件。
我可以从父视图继承域数据源吗?
private void ApproveCmd_Click(object sender, RoutedEventArgs e)
{
PA_Request selReq =(PA_Request) this.onticPMA_RequestRadGridView.SelectedItem;
if (selReq != null)
{
((PA_Request)this.PA_RequestRadGridView.SelectedItem).STATUS = "Approved";
this.PA_RequestDomainDataSource.SubmitChanges();
}
}
private void DissaproveCmd_Click(object sender, RoutedEventArgs e)
{
PA_Request selReq = (PA_Request)this.PA_RequestRadGridView.SelectedItem;
if (selReq != null)
{
((PA_Request)this.PA_RequestRadGridView.SelectedItem).STATUS = "Disapproved";
this.PA_RequestDomainDataSource.SubmitChanges();
}
}
private void ApplyCmd_Click(object sender, RoutedEventArgs e)
{
PA_Request selReq = (PA_Request)this.PA_RequestRadGridView.SelectedItem;
if (selReq != null)
{
((PA_Request)this.PA_RequestRadGridView.SelectedItem).STATUS = "Applied";
this.PA_RequestDomainDataSource.SubmitChanges();
}
答案 0 :(得分:0)
好的,假设网格中有10个元素。当您点击任何项目时,会打开一个事件,请说出ApproveCmd_Click。您需要先检索这样的发件人。
private void ApproveCmd_Click(object sender, RoutedEventArgs e)
{
var senderListBox = sender as ListBox; (Or any type you want)
var senderListBoxItem = senderListBox as senderListBoxItem;
string data = senderListBoxItem.Content;
//Now you have sender.
// Pass sender through constructor of the window
//Say you need to pass a string Create
var chieldWindow = new ChieldWindow(data);
}
在chield window中
class ChieldWindow :Window
{
ChieldWindow(string input)
{
\\You got the data
}
}
Lemme know