简体   繁体   中英

Adding Static Rows to DataGrid Columns

Is there a way to add static rows to DataGrid using XAML only? I have a DataGrid which consists of only one column. This column has some rows which change depending on the users input, but has two rows which are always there no matter what user's input is. I want to avoid creating additional collection in order to bind the content of the column, but to bind only to the changable part of the column, and add two static rows. Is it possible to do this in XAML?

Static record may be problematic when you use ItemsSource (which will throw an exception when any record exists). I would prepare a Boolean property for record model class that indicates editable or not, and bind it to eg IsEnabled . In your case, first two items are declared on the code with the property of false (not pure XAML solution, though).

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