开发者

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);
  开发者_Go百科}
}

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜