将所选行(通过复选框)从一个网格视图发送到另一个

时间:2015-09-06 11:49:26

标签: c# wpf

我在一个页面上有一个gridview,我想只将选定的行从该gridview发送到另一个gridview,这是下一页的一个。

以下是所选行的代码:

private void TestCheckBox_Checked(object sender, RoutedEventArgs e)
{
    var chk = (CheckBox)sender;enter code here
    var row = dgUsers.Items[0].ToString();
    object item = dgUsers.SelectedItem;
    string ID = (dgUsers.SelectedCells[0].Column.GetCellContent(item) as TextBlock).Text;
    string Name = (dgUsers.SelectedCells[1].Column.GetCellContent(item) as TextBlock).Text;
    Product p1 = new Product();//class of product
    p1.ID = ID;
    p1.Name = Name;
}

public partial class Window1 : Window
{
    public Window1()
    {
        InitializeComponent();
    }

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        Product p1 = new Product();
        dg.Items.Add(p1.ID);
        dg.Items.Add(p1.Name);   
    }
}

0 个答案:

没有答案