DataGrid becomes out of control!!

Aug 5, 2009 at 9:49 AM

Hi,

I am just trying to refresh a datagrid (10 columns) each 500ms. Each 500ms I add 20 items to the datagrid.

Everything works fine when I start the project with a 300x300 window.

However if I try to put the window to a full screen all the element of the datagrid become out of control. I cannot even close the window anymore!!

I think the problem comes from the number of rows as if I put only three columns, everything works fine.

Can anyone help me on this?

What am I doing wrong?

I managed to reproduce the problem, below is the very simple code.

Thanks,

Kamel

 

 

<Window x:Class="DGRefresh.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300" xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit">
    <Grid>
        <my:DataGrid AutoGenerateColumns="True"  Name="dataGrid1"  />
    </Grid>
</Window>

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Timers;

namespace DGRefresh
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        private List<Trade> _ListOfTrade = new List<Trade>();

        public Window1()
        {
            InitializeComponent();

            EditListOfTrade();
            dataGrid1.ItemsSource = _ListOfTrade;

            // We create a timer which will send an event each 500ms to refresh the dataGrid
            Timer aTimer = new Timer();
            aTimer.Elapsed += new ElapsedEventHandler(aTimer_Elapsed);
            aTimer.Interval = 500;
            aTimer.Enabled = true;
        }

        void aTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            dataGrid1.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
                  (System.Threading.ThreadStart)delegate()
                  {
                      EditListOfTrade();
                      dataGrid1.Items.Refresh();
                  }
                  );
        }

        void EditListOfTrade()
        {
            for (int i = 0; i < 20; i++)
            {
                Trade trade = new Trade();
                _ListOfTrade.Add(trade);
            }
        }
    }

    class Trade
    {
        private Random random = new Random();

        public double Field1 { get { return random.NextDouble(); } }
        public double Field2 { get { return random.NextDouble(); } }
        public double Field3 { get { return random.NextDouble(); } }
        public double Field4 { get { return random.NextDouble(); } }
        public double Field5 { get { return random.NextDouble(); } }
        public double Field6 { get { return random.NextDouble(); } }
        public double Field7 { get { return random.NextDouble(); } }
        public double Field8 { get { return random.NextDouble(); } }
        public double Field9 { get { return random.NextDouble(); } }
        public double Field10 { get { return random.NextDouble(); } }
    }
}

 

 

Aug 5, 2009 at 1:28 PM

What is the configuration of your computer? Your program works fine on my system (A dual core CPU running at 2.4G with 4G Ram; running on Windows 7). I suggest that you can use the task manager to check if you have sufficient resource to run this program.

Aug 5, 2009 at 11:55 PM
A dual core CPU running at 2.4G with 3G Ram running on vista. I have no problem with my resources.

Have you try to put the window on a full screen and wait for 5-10 seconds?

Thanks,
Kamel

2009/8/5 achau <notifications@codeplex.com>

From: achau

What is the configuration of your computer? Your program works fine on my system (A dual core CPU running at 2.4G with 4G Ram; running on Windows 7). I suggest that you can use the task manager to check if you have sufficient resource to run this program.

Read the full discussion online.

To add a post to this discussion, reply to this email (wpf@discussions.codeplex.com)

To start a new discussion for this project, email wpf@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Aug 6, 2009 at 6:00 AM

Yes, I had run it at full screen for more than 10 minutes without any problem. I ran it on a Fujitsu S6520 notebook with a screen of 1280x768 and a Intel graphic chip. I also ran the program on Quad core 3.2G desktop computer with a screen resolution of 1920x1080 and a Nvidia graphic card for 10 minutes.

Do you have a second computer to test your program? The followings are the possible differences of our environment:

1) I am using Windows 7 on both machines.

2) I am using the June build of WPF toolkit.

3) Besides the standard 3.5 SP1 .Net framework, I had installed KB958484 and silverlight toolkit to fix some issues of the Visual studio designer.

Aug 6, 2009 at 6:48 AM

Hi,

I just found a problem of your program on my desktop system. The response of the datagrid and the window is very bad under 1920x1080 full screen resolution.  For example, it may take around 4 seconds for the DataGrid to response to any mouse click event. It seems that your program make the WPF system very busy and it is slow to response to the hit test event. Let's see whether there are good suggestion to fix this issue.