Editor for SecureString

Grids for WPF Forum

Posted 12 years ago by Valéry Sablonnière - Staubli
Version: 12.1.0562
Avatar

Hi,

do you have a sample of a PasswordPropertyEditor in order to edit a SecureString in a PropertyGrid ?

If not, can you explain how to implement it easily ?

Best regards.

Comments (5)

Answer - Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi,

I'm sorry but I don't believe we have a built-in property editor for editing a SecureString.  However the Editors portion of the Sample Browser has a demo called PropertyGridIntegrationCustom that shows how to make a custom property editor.  You could use this sort of info with our Editors' PasswordBox or even the native WPF PasswordBox.


Actipro Software Support

Posted 12 years ago by Valéry Sablonnière - Staubli
Avatar

Hi,

yes, actually I saw this sample but can you give me the steps to implement this ?

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

That particular demo has several extra classes that you don't need to focus on.  For instance you can ignore PositiveDoublePropertyEditor, RotationDoublePropertyEditor, SkewDoublePropertyEditor, and TestObject.

You'd just clone the rest of the classes and rename them from using Rect in the names to Password.  Instead of using a RectEditBox in the template within PropertyEditors.xaml, you'd use a PasswordBox.


Actipro Software Support

Posted 12 years ago by Valéry Sablonnière - Staubli
Avatar

Actually it's not as easy as the RectEditBox, it's not possible to use "bindings" with the password property of the PasswordBox.

So my idea was to create a type which inherits from PasswordBox and use the PasswordChanged event to update the value of the IPropertyDataAccessor.

The problem is: how to initialize the PasswordBox with the value of the IPropertyDataAccessor object ?

Is it the good way to do it ?

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

True, you won't be able to bind to the Password property since it's not a dependency property.  I'd probably recommend that in your inherited class you create a new string dependency property and watch for changes on that.  In the XAML template bind the data accessor's value to it.  When you get changes to it you can pass them on to the PasswordBox.Password property and when you see PasswordChanged events, pass those back and update your new dependency property's value (as long as there is a change).


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.