从datagrid中的行获取所有单元格数据

时间:2017-01-04 11:24:05

标签: c# wpf

private void rowAnagrafiche_DoubleClick(object sender, MouseButtonEventArgs e)
    {
        hideAllPanels();
        this.panelCreaAnagrafica.Visibility = Visibility.Visible;

        var labelTemp = (TextBox)this.panelCreaAnagrafica.FindName("txtCod");
        labelTemp.Text = (FIRST DATA CELL);
        labelTemp = (TextBox)this.panelCreaAnagrafica.FindName("txtGruppo");
        labelTemp.Text = (SECOND DATA CELL);
        labelTemp = (TextBox)this.panelCreaAnagrafica.FindName("txtRagSoc");
        labelTemp.Text = (THIRD DATA CELL);
    }

这是我的xaml

我被卡住..我无法从点击的行中获取所有数据单元..

点击后我应该用setset textbox打开“panelCreaAnagrafica”

function strip_subdomains($url){

    # credits to gavingmiller for maintaining this list
    $second_level_domains = file_get_contents("https://raw.githubusercontent.com/gavingmiller/second-level-domains/master/SLDs.csv");

    # presume sld first ...
    $possible_sld = implode('.', array_slice(explode('.', $url), -2));

    # and then verify it
    if (strpos($second_level_domains, $possible_sld)){
        return  implode('.', array_slice(explode('.', $url), -3));
    } else {
        return  implode('.', array_slice(explode('.', $url), -2));
    }
}

1 个答案:

答案 0 :(得分:0)

您可以将事件处理程序的sender参数强制转换为DataGridRow,然后将其DataContext强制转换为具有“cod”,“gruppo”,“nome”属性的类型,例如:

private void rowAnagrafiche_DoubleClick(object sender, MouseButtonEventArgs e)
{
    DataGridRow row = sender as DataGridRow;
    if (row != null)
    {
        dynamic dataObject = row.DataContext;
        string nome = dataObject.nome;
    }
}