简体   繁体   中英

Dynamically adding columns to a DataGrid

I've been trying to find a solution to this but I couldn't find what I was looking for so ultimately I think I need to change my project type but figured I'd ask in case someone can save me time / educate me.

I have a console project that is using a created Window Form to allow some front end user interaction, but because of this I can only use a DataGrid. (The project is evolving as I make it that's why I'm in this situation.)

I would like to make something like this using a class if possible. I made the example by doing the hardcoded XAML way
XAML
在此处输入图像描述
after its made using the C# below. (Red is not there I added that)
要创建的表

This is what I have so far.
C#
在此处输入图像描述
If anyone can help me out with this it would be very much appreciated!

I ended up figuring this out because of another post after searching for a while. I'll just post my final solution in case anyone was wondering or stumbles upon this post.
C#
在此处输入图像描述
XAML
在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM