I've spend the past months reading questions, answers and advice on StackOverflow. I'm a beginner in C#, .Net, WPF and MVVM. I'm developing a PMS (property management system) for a friend's hotel.
I've often been stuck for days on some problems. So much to learn!!
Anyway.. Here's a problem that is SO annoying, I just thought I'd finally asked for advice directly...
I have a DataGrid with one frozen column that holds a list of Amenities (text). The following columns' headers contain the names of Rooms (or rather, room types). Some room types have airco, others don't, some have tv, some dont... This datagrid is supposed to be filled with checkboxes to allow the manager of a hostel to indicate which room types possess which amenities.
I have a class that I'd like to use for the itemssource's bound observable collection.
public class RoomTypesAmenityItem
{
public string AmenityName { get; set; }
public IList<RoomTypeItem> RoomTypeList { get; set; }
public IList<bool> AmenitiesCheckList { get; set; }
public RoomTypesAmenityItem(string name, IList<RoomTypeItem> list, IList<bool> checklist)
{
AmenityName = name;
RoomTypeList = list;
AmenitiesCheckList = checklist;
}
}
The list with bools would be used to set the checkboxes' IsChecked value. The list with RoomTypeItem objects is supposed to help with a faster/easier identification of which object's checkbox has been checked/unchecked. (I suppose I'll use it, so I put it there already...)
Now, I don't know how to proceed. I was thinking of adding the frozen column in XAML manually. And then autogenerating the other columns, using a datatemplate or so that sets the IsChecked value with a IMultiValueConverter (passing the column's index, and the current row's object). I've also thought about not autogenerating anything, but simply manually adding columns.. but then I need a template column that I can copy, and which would set the binding using something like string.Format(AmenitiesCheckList[{0}], columnIndex) ...
Those are the ideas I have.. But I have no clue how to actually get one to work. It's all a huge mess in my mind. Misconceptions, things I thought I understood but apparently don't, things I didn't learn yet, ...
If somebody who understands my need clearly, could help me out with some precise advice or good code.. I'd be immensely thankful! I never before asked help. Pointers to decent documentation, tips on what to learn/read in order to be able to do this myself.. all is welcome. But i'm in kind of a rush to finish this simple-looking little screen quickly...... So code would be wonderful!
Sorry for the long message.
Let me know if more info is needed.. ?
(as to how to handle the changes when a checkbox is clicked.. I guess that's for another topic.. but I would appreciate if you had advice to go with a possible solution already.. )