Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WPF数据网格值未更新_C#_Wpf - Fatal编程技术网

C# WPF数据网格值未更新

C# WPF数据网格值未更新,c#,wpf,C#,Wpf,在这里,我试图更改“DateCreated”列中所有单元格的日期格式。My值已正确转换,但未显示在我的DataGrid上 我哪里出了问题 public static void refreshTicketData(DataTable dt1, DataGrid TicketDG) { using (Global.cmd = new SqlCommand("Select INDEX_Tickets, Status, DateCreated,DateClosed from Tickets W

在这里,我试图更改“DateCreated”列中所有单元格的日期格式。My值已正确转换,但未显示在我的DataGrid上

我哪里出了问题

public static void refreshTicketData(DataTable dt1, DataGrid TicketDG)
{

    using (Global.cmd = new SqlCommand("Select INDEX_Tickets, Status, DateCreated,DateClosed from Tickets WHERE Customer_ID ='" + Global.CustomerID + "'", Global.cs))
    {
        dt1 = new DataTable();
        dt1.Load(Global.cmd.ExecuteReader());


        int count = 0;
        foreach (DataRow row in dt1.Rows)
        {
            string getCurrent = row["DateCreated"].ToString();
            DateTime readDate = DateTime.Parse(getCurrent);
            string finalDate = readDate.ToString("dd-MM-yyyy");


            dt1.Rows[count]["DateCreated"]=finalDate;
            count++;             
        }
        TicketDG.ItemsSource = dt1.DefaultView;
    }         
}

尝试添加TicketDG.Items.Refresh();在Itemsource updateNah之后,没有更新UI。我一直在研究如何使用INotifyPropertyChanged。看起来很复杂,但从长远来看是值得的。有没有人有好的学习资源?你可以看看你在屏幕上看到了什么?在XAML中如何定义TickerDG?