WPF DataGrid - Why the extra column

前端 未结 4 540
轻奢々
轻奢々 2021-01-03 18:59

I have a WPF app that uses DataGrid to display some data. When I run the program there is an additional column as shown here:

4条回答
  •  萌比男神i
    2021-01-03 19:57

    The "extra column" is actually just unused space. Each of your columns define a Width value, so once they get assigned there is space left over.

    If you want to get rid of that space, make at least one of your columns a * column so it stretches to fill available space.

    My best guess as to why it looks normal in Visual Studio is probably because you have the designer width set to something smaller than the runtime width. If it were larger, you'd see the same thing.

    If you don't want your control to stretch, then be sure to set it's (or it's parent's) horizontal/vertical alignment to something other than Stretch

    
        
    
    

提交回复
热议问题