I have implemented a "Property Editor" style control for our application that utilizes a RadGridView. By utilizing standard and custom .NET attributes, we allow for custom editing of properties from any user-configurable object within our product. The user is also able to display properties alphabetically or by category. I implement editing by creating a custom column type that inherits from GridViewDataColumn and overrides the CreateCellEditElement method.
The RadGridView has really served us nicely in this respect. Recently, a request was made to support "Password" class properties. Implementing the editor was trivial using the PasswordBox control. However, I'm running into issues when trying to mask the password's value when not in edit mode.
Currently, I have defined a style that sets the Foreground font color to "Transparent" if the editor type is "Password":
This style is then utilized by the custom column class (inherited from GridViewDataColumn):
This works well, but it's not was I would like to do. By setting the foreground font color, it gives the impression to the user that their entry was not accepted by the program. I would really like to mask the password with a character in the cell similar to what the PasswordBox control does. When I attempt to set the ContentTemplate with a control (TextBlock or PasswordBox), I loose the ability to edit the cell's contents. The row will go into edit mode, but the edit control is not displayed even though the CreateCellEditElement method is being executed.
What's the best way to implement such a method of data masking?
...Glenn
The RadGridView has really served us nicely in this respect. Recently, a request was made to support "Password" class properties. Implementing the editor was trivial using the PasswordBox control. However, I'm running into issues when trying to mask the password's value when not in edit mode.
Currently, I have defined a style that sets the Foreground font color to "Transparent" if the editor type is "Password":
<
Style
TargetType
=
"telerik1:GridViewCell"
x:Key
=
"ValueCellStyle"
>
<
Style.Triggers
>
<
DataTrigger
Binding
=
"{Binding Path=Editor}"
Value
=
"Password"
>
<
Setter
Property
=
"Foreground"
Value
=
"Transparent"
/>
</
DataTrigger
>
</
Style.Triggers
>
</
Style
>
This style is then utilized by the custom column class (inherited from GridViewDataColumn):
<my
:ConfigDataColumn
Header
=
"Value"
DataMemberBinding
=
"{Binding Value, Mode=TwoWay}"
Width
=
"300"
IsReadOnly
=
"False"
CellStyle
=
"{StaticResource ValueCellStyle}"
/>
This works well, but it's not was I would like to do. By setting the foreground font color, it gives the impression to the user that their entry was not accepted by the program. I would really like to mask the password with a character in the cell similar to what the PasswordBox control does. When I attempt to set the ContentTemplate with a control (TextBlock or PasswordBox), I loose the ability to edit the cell's contents. The row will go into edit mode, but the edit control is not displayed even though the CreateCellEditElement method is being executed.
What's the best way to implement such a method of data masking?
...Glenn