CustomControl not firing EndEdit

Feb 2, 2010 at 12:19 PM

I have a DataGridTemplateColumn that uses a custom controll in the CellEditingTemplate.

The custom control consists of a Grid containing a TextBox and a Button.

The custom control also has a string dependency property, called "SelectedPath".

The TextBox Text dependency property in the TextBox is bound to the SelectedPath of the wrapping custom control.

The Button opens a folder browser, and when that is closed sets the dependency property "SelectedPath" to the folder browsed to.

The row item implements IEditableObject.

When the TextBox is edited, IEditableObject.EndEdit() is called when leaving the cell.

However, when setting the dependency property "SelectedPath" after clicking on the button, and browsing to a folder and clicking "OK", IEditableObject.EndEdit() is not called.

What is the simplest and most correct way of making sure IEditableObject.EndEdit() is called, when using the folder browser dialog?

Thanx!

 

- Steinar

Feb 2, 2010 at 2:03 PM

I by putting breakpoints in the IEditableObject.BeginEdit() implementation, and looking at the stack when stopped in the breakpoint, I see that it seems to be called as a result of the left mouse button being clicked inside the cell.

The button in the custom control has the following in XAML: Click="BrowseButtonClick"

Could it be that this makes the button "eat" the mouse down events before the datagrid cell sees it?

What could I do to avoid it?  Some other way of getting the mouse click from the button?  Using data bindings perhaps?

Feb 2, 2010 at 3:17 PM
steinarb wrote:

I by putting breakpoints in the IEditableObject.BeginEdit() implementation, and looking at the stack when stopped in the breakpoint, I see that it seems to be called as a result of the left mouse button being clicked inside the cell.

The button in the custom control has the following in XAML: Click="BrowseButtonClick"

Could it be that this makes the button "eat" the mouse down events before the datagrid cell sees it?

What could I do to avoid it?  Some other way of getting the mouse click from the button?  Using data bindings perhaps?

 It does indeed look like Button eats all mouse events: http://www.devx.com/dotnet/Article/40650/1763/page/3

Is there a way to convince Button to let them trickle through?