Silverlight 3 Dataform Commit Button not activating

纵然是瞬间 提交于 2020-01-06 16:34:15

问题


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.


回答1:


The DataForm assumes a single object not a collection for the commit button. Can you explain your bound data a little clearer?

It may be that in your AddRange yuo are not using the INotifyCollectionChanged interface right? (can't tell from the example). Otherwise it looks like you're doing the right thing.




回答2:


I had the same isue using silverlight 4 and RIA serivces.

I resolved installing the WCF RIA Services Service Pack 1 and re-installing the WCF RIA Services Toolkit for WCF RIA Services SP1.

This two installer can be found at: http://www.silverlight.net/getstarted/riaservices/

Direct link to WCF RIA Services SP 1: http://go.microsoft.com/fwlink/?LinkId=205085 Direct link to WCF RIA Services toolkit for WCF RIA Services SP1: http://go.microsoft.com/fwlink/?LinkID=205088




回答3:


Check whether your binding mode is twoway for properties binded to dataform. This will activate your OK cancel buttons.



来源:https://stackoverflow.com/questions/1499645/silverlight-3-dataform-commit-button-not-activating

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!