Click here to Skip to main content
13,000,164 members (45,895 online)
Rate this:
Please Sign up or sign in to vote.
See more:
    <DataGrid AutoGenerateColumns="False"
              ItemsSource="{Binding Path=Database}">
            <DataGridTextColumn Width="Auto"
                                Binding="{Binding Path=Integer}"
                                Header="String" />
            <DataGridTextColumn Width="Auto"
                                Binding="{Binding Path=String}"
                                Header="String" />

This is my Xaml example code to reproduce the problem... there is no code behind.

class DataGridViewModel
        public class Data
            #region properties
            public int Integer { get; set; }
            public string String { get; set; }
            public double Double { get; set; }
            #region instance constructors
            /// <summary>
            /// Initializes a new instance of the <see cref="Data"/> class.
            /// </summary>
            public Data(int i, double d, string s)
                /* initializes all instance members */
                Integer = i;
                Double = d;
                String = s;
        private readonly List<Data> _database = new List<Data>(10);
        public IEnumerable<Data> Database
            get { return _database; }
        public DataGridViewModel()
            /* initializes all instance members */
            _database.Add(new Data(1, 1.5, "test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1"));
            _database.Add(new Data(2, 2.5, "test2test2test2test2test2test2test2test2test2test2test2test2test2test2test2test2test2test2"));
            _database.Add(new Data(3, 3.5, "test3test3test3test3test3test3test3test3test3test3test3test3test3test3test3test3test3test3"));
            _database.Add(new Data(4, 4.5, "test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4test4"));
            _database.Add(new Data(5, 5.5, "test5test5test5test5test5test5test5test5test5test5test5test5test5test5test5test5test5test5"));
            _database.Add(new Data(6, 6.5, "test6test6test6test6test6test6test6test6test6test6test6test6test6test6test6test6test6test6"));
            _database.Add(new Data(7, 7.5, "test7test7test7test7test7test7test7test7test7test7test7test7test7test7test7test7test7test7"));
            _database.Add(new Data(8, 8.5, "test8test8test8test8test8test8test8test8test8test8test8test8test8test8test8test8test8test8"));
            _database.Add(new Data(9, 9.5, "test9test9test9test9test9test9test9test9test9test9test9test9test9test9test9test9test9test9"));
            _database.Add(new Data(10, 10.5, "test10test10test10test10test10test10test10test10test10test10test10test10test10test10test10"));

this is the view model.

Problem: If I set the column width to "auto" the horizontal scroll bar shows as wished but if the window gets to big i can't select a row in the last empty column.

If I set the column width to "*" the empty column is removed and i can select a row everywhere in the data grid. Now I have a Problem with the horizontal scroll bar, which isn't shown or if it gets shown some times i can't scroll and my text gets cut.

Posted 27-May-13 4:17am
Updated 27-May-13 4:19am
govardhan4u 28-May-13 2:23am
try to keep use the horizontal scroll bar poperty or keep that grid inside the scrollview tags

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 27 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100