I'm writing a ChecklistBox control, which is a listbox that renders CheckBoxes inside the list. I'm then using this control inside of a DataForm's EditTemplate. Along with this control, I've got two text boxes that are bound to properties of the DataContext of the Dataform.
For reference, the ChecklistBox has three implemented properties...
- ItemsSource -> the list of possible items to have for the collection on your object.
- ObjectCollection -> the collection of objects that should be affected... think your order details in this scenario.
- CheckboxContentTemplate -> this is what should be shown next to the checkbox in the list (typically, this is just the text of the object, but it could be anything.)
What I'm running into is that the Dataform's Commit button won't activate when I change the ObjectCollection. However, if I change the text of either textbox in the edittemplate during the execution of the program, my Commit button activates.
Any ideas?
@Shawn:
I have two objects, Users & Roles...
public class Users : INotifyPropertyChanged, IEditableObject
{
public string firstname {get{...}set{...}}
public string lastname {get{...}set{...}}
public RoleCollection Roles {get{...}set{...}}
}
public class Role : INotifyPropertyChanged, IEditableObject
{
public Guid Oid {get{...}set{...}}
public string Code {get{...}set{...}}
public string Name {get{...}set{...}}
public string Description{get{...}set{...}}
}
public class RoleCollection:BulkObservableCollection<Role>
{
}
public class BulkObservableCollection<T>:ObservableCollection<T>
{
public void AddRange(IList toAdd)
{
...
}
}
let's say for arguement's sake that the above code has all the proper structure to handle the events in INotifyPropertyChanged and IEditableObject. When I go and build the checklistbox, I'm looking at the ObjectCollection ("user".Roles.Where(item => Item.Oid == role.Oid).Count > 0;) to say whether or not to initially check the checkbox or not.
I know for fact that when I uncheck and check the boxes, the "DataContext" of the role is being added or removed from the object, as I traced it out. I'd like to somehow alert the dataform that when I remove an object from "Roles", that it is altering the object.
I tried capturing the CollectionChanged event from ObservableCollection, and then firing off a "PropertyChanged("Roles")" event, but that didn't seem to solve it.