I'm sure I must be doing something really simple and stupid wrong, but I can't for the life of me work it out.
For some reason, one of the columns I have defined is not binding to the underlying row. The key and name is correct (EntityId). And the rest of the columns bind correctly. But the behaviour of the 'EntityId' column is quite strange. The column uses a User Control which works correctly in all other parts of the interface. But in the XAM Grid Templated Column it doesn't.
I go to the AddNew Row. I fill all of the cells. Then when I commit the Row, the row is added to the list below, except that the EntityId is blank (null) in the newly added Row. But in the AddNew row, the EntityId is still set with whatever value I have chosen. On further inspection, the CellExitingEditMode is called when leaving all the other cells, but is not fired when exiting the 'EntityId' cell.
The Column is defined as below (sorry I don't know how to format it into a fixed length font) :
EntitySelector is defined as follows (reduced) :
public class EntitySelector : TextBox
{
// ENTITY ID
EntityType = EntitySymbol ==
null ? null : EntitySymbol.EntityType;
DisplaySymbol = NewDisplaySymbol;
}
// Using a DependencyProperty as the backing store for EntityId. This enables animation, styling, binding, etc...
EntityIdProperty = DependencyProperty.Register("EntityId", typeof(int?), typeof(EntitySelector), new PropertyMetadata(null));
... (logic)
Hi,
It's hard to say exactly whats going on without a sample, but here are a few observations from your code.
1. The editing events, only work when you use the EditTemplate of a TemplateColumn.
2. You're using a DP for the EntitiyId, but your logic for handling when EntityId is set, is in the Setter of the property. That means your code won't get hit, when the property changes via a binding. You should always put your logic for handling the changing of a DP in the property change handler of the DP,
For example:
#region EntityId /// <summary> /// Identifies the <see cref="EntityId"/> dependency property. /// </summary> public static readonly DependencyProperty EntityIdProperty = DependencyProperty.Register("EntityId", typeof(int?), typeof(EntitySelector), new PropertyMetadata(new PropertyChangedCallback(EntityIdChanged))); public int? EntityId { get { return (int?)this.GetValue(EntityIdProperty); } set { this.SetValue(EntityIdProperty, value); } } private static void EntityIdChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { // Logic for handling the changing of the property should go here. }
#endregion // EntityId
-SteveZ