How do you handle this situation?

How do you handle this situation?

Old forum URL: forums.lhotka.net/forums/t/6315.aspx


dgataglc posted on Monday, February 02, 2009

I want to call my Save method from a menu command button but I'm having issues with getting my properties to update accordingly without first having to tab out of the editable control.

(I'm creating a WPF data form)

For example, I've got a business object with three properties, ID, Name and Age.  The Save menu item is bound to the object so it's enabled/disabled properties act accordingly which is what I want.  There is one exception though.  If I first update the Name, the Save button enables as it should.  But if I then update the Age without tabbing out of the control I can't successfully Save the data I entered as the control never loses focus when a menu item is selected.  (The Name is updated but the Age isn't)

Is this effect a desired result or what am I missing to resolve this.  My users don't want to tab out of the last field their updating.  They just like to mouse over to the Save menu.  Right now if I leave it the way things are they'll end up losing the last fields updates.

Thoughts???

JoeFallon1 replied on Monday, February 02, 2009

This is an ancient problem - it is not new to WPF.

You can try and find an event which you can handle and then re-set the focus yourself so that the last value is "posted" to the BO when the user clicks the menu.

Note: The event you are looking for is not in the Menu but somewhere in the form or grid.

Joe

 

tetranz replied on Monday, February 02, 2009

I don't know about WPF but in Windows forms you can call the form's Validate method when the menu is clicked. I do that for toolbar buttons because they don't do the validate (and therefore send the data to the object) either.

Copyright (c) Marimer LLC