How to access cells of WPF Toolkit DataGrid?

Apr 14, 2010 at 10:15 PM
Edited Apr 14, 2010 at 10:17 PM

Hi! I'm trying to retrieve and modify the value of a cell in a WPF Toolkit datagrid but I can't figure out how I can do it. My test application contains only a datagrid which displays an IEnumerable<string>.


        <Toolkit:DataGrid ItemsSource="{Binding Numbers}" AutoGenerateColumns="False">
                <Toolkit:DataGridTextColumn Header="Number" IsReadOnly="True" Binding="{Binding}" />

In my test, I get the data grid by window.Get<ListView>(). I can also access the header and its columns and I also see that the data grid has some rows, but I cannot access the cells collection because it is always empty. Am I doing something wrong? Here is my test fixture:

    public class When_adding_numbers
        private Application _application;
        private Window _window;

        public void BeforeEveryTest()
            _application = Application.Launch(typeof (Shell).Assembly.GetName().Name + ".exe");
            _window = _application.GetWindows().Single();


        public void Should_add_number_to_list_box()
            var listView = _window.Get<ListView>();
            System.Diagnostics.Debug.WriteLine("cell count: " + listView.Rows[0].Cells.Count);
            Assert.That(Convert.ToInt32(listView.Rows[0].Cells[0].Text), Is.GreaterThanOrEqualTo(10).And.LessThan(100));

        public void AfterEveryTest()


 Best Regards, Oliver Hanappi

Apr 15, 2010 at 10:50 AM



have a look here: WPF DataGrid


may that will help you