简体   繁体   中英

datagrid behaving abnormally when itemsource is very large

I am seeing abnormal behavior in datagrid when the item source is very large list(>4000) like the columns are disappearing while scrolling horizontal scroll bar and even extra column(i mean repeated columns) are appearing rather than specified.

Here is my xaml code.

    <TK:DataGridTextColumn Header=" Date" Binding="{Binding Date}" MinWidth="70"/>
    <TK:DataGridTextColumn Header=" Time" Binding="{Binding Time}"  MinWidth="70"/>
    <TK:DataGridTextColumn Header=" Severity"  Binding="{Binding Severity}" MinWidth="70" />
    <TK:DataGridTextColumn Header=" Message"  Binding="{Binding Message}" MinWidth="70" Width ="1*"/>
</TK:DataGrid.Columns>
</TK:DataGrid>

here is my code behind

enter code here

public Window1()

{
  pLogList = new List<LogList>();
  InitializeComponent();
  try
  {
    pLogList = new List<LogList>();
    pLogList.Add(new LogList(DateTime.Now, "Hello World", "Success", "GUI")); //LogList is a class and i hav written each properties to bind to datagrid
  datagridtest.ItemsSource = pLogList;
  }
  catch (Exception pEx)
  {
    // MessageBox.Show(pEx.Message);
  }
}

here is my LogList class

enter code here
public class LogList
  {
    public LogList(DateTime date,string mess,string sev,string time)
    {
      m_Date = date;
      m_Time = time;
      m_Severity = sev;
      m_Message = mess;
    }
    string m_Time;
    string m_Message;
    string m_Severity;
    DateTime m_Date;
    public DateTime Date
    {
      get
      {
        return m_Date;
      }
      set
      {
        m_Date = value;
      }
    }
    public String Message
    {
      get
      {
        return m_Message;
      }
      set
      {
        m_Message = value;
      }
    }
    public String Severity
    {
      get
      {
        return m_Severity;
      }
      set
      {
        m_Severity = value;
      }
    }
    public String Time
    {
      get
      {
        return m_Time;
      }
      set
      {
        m_Time = value;
      }
    }
  }

I hope that i am clear with my problem and look forward for a solution

Thanks Everyone

Try to play around with the Column- and RowVirtualization Properties of the DataGrid.

These properties are mostly the culprits of such issues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM