Feature Requests

Editors for WPF Forum

Posted 10 years ago by Phil Devaney - Senior Software Engineer, Serck Controls Ltd
Version: 9.1.0503
Avatar
I have a couple of feature requests for PartEditBox:
- Add an IsReadOnly property similar to the standard TextBox, that allows selection of the text in the control without being able to edit it.
- Add a way of automatically updating the source of any binding on the Value property when either the drop down is closed or the spinner is used, without having to set UpdateSourceTrigger=PropertyChanged on the binding. I have managed to implement this for drop down close using an attached behaviour, but I have to use reflection to find the Value DP so I think this would be better as standard behaviour. I haven't managed to implement it for spinner change as I can't find a suitable event to hook.

Thanks

Phil

Comments (4)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Phil,

I've added your request for an IsReadOnly property to our TODO list.

For your second item, you should be able to use GetBindingExpression() to get the underlying BindingExpression on the ValueProperty. So for a DateTimeEditBox, you'd have:
BindingExpression be = this.dateTimeEditBox.GetBindingExpression(DateTimeEditBox.ValueProperty);
To update the source when spinning, you could derive from the specific control (e.g. MyDateTimeEditBox) and override OnExecutedIncrementValue/OnExecutedDecrementValue and add your code there. Keep in mind that pressing the up/down arrows when a spinnable part has focus, also calls these same methods.

If you can explain more your ultimate goal, we can see about adding some additional and generalized hooks.


Actipro Software Support

Posted 10 years ago by Phil Devaney - Senior Software Engineer, Serck Controls Ltd
Avatar
I am using the PartEditBox in a property grid, with a two-way binding on the Value property. What I wanted was a way to push the value back to the binding source immediately when the drop down is closed, to provide a more immediate editing experience similar to a standard combo box, rather than waiting for the control to lose focus. I don't want to use UpdateSourceTrigger=PropertyChanged on the binding as I don't want typing in the PartEditBox to update the binding source immediately.

I've emailed a sample that shows how this works with my attached behaviour implementation (see http://www.codeproject.com/KB/WPF/AttachedBehaviors.aspx if you aren't familiar with this pattern). The important code is in PartEditBoxBehaviors.cs. The problem is that I want the behaviour to be reusable with any type of PartEditBox, so I have to use reflection to find the ValueProperty field as it is type-specific and doesn't exist on the base class.

Implementing something similar for the spinner is difficult without deriving and losing genericity. I also thought this might be a useful feature for other people :)

[Modified at 07/30/2009 04:41 AM]
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Phil,

Assuming you have UpdateSourceTrigger set to PropertyChanged on the EditBox.Value property, then by default the parts will not commit any typing changes up to the EditBox.Value until the user presses Enter or the part loses focus. Also by default, it will commit any changes made by spinning up to the EditBox.Value property immediately. This is controlled by the EditBox.PartValueCommitTriggers property.

Under this scenario, if the user types in a new value for the X part of a PointEditBox and tabs over to the Y part, then the change made to the X part will be committed up (and picked up by the binding). If I understand correctly and based on your sample, you don't want the change to be commited up until after the user gets a chance to enter a new Y value *and* the focus is moved out of the control. Is that correct?

If so, the only problem I would forsee is if the user types in a new X value, tabs to the Y part, and then spins the Y value. This would commit both the X and Y value, which may be confusing. Mainly because the user doesn't alway know if the value presented by the other part(s) has been "commited". As it is now, only the focused part may not be "commmited".


Actipro Software Support

Posted 10 years ago by Phil Devaney - Senior Software Engineer, Serck Controls Ltd
Avatar
I have just tried using UpdateSourceTrigger=PropertyChanged and I like the way it works better than what I was asking for! I guess I just didn't try it as I assumed it would work like TextBox and update on every key stroke, which is what I don't want. I currently only use the spinner on Int & Double editors, so there will be no confusion on that front.

Thanks for your time.
The latest build of this product (v2019.1 build 0682) was released 26 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.