This project has moved. For the latest updates, please go here.

Propertygrid password

Jul 20, 2013 at 4:18 AM
Is there a way to tell the propertygrid a string is a password to get the mask? -Thanks
Dec 4, 2013 at 7:08 PM
Can't you add a EditorTemplateDefinition that contains a PasswordBox ?
Dec 5, 2013 at 2:32 AM
I ended up using an ITypeEditor:
public class PasswordEditor : Xceed.Wpf.Toolkit.PropertyGrid.Editors.ITypeEditor
    Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem m_PropertyItem;
    PasswordBox m_PasswordBox;

    public FrameworkElement ResolveEditor(Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyItem)
        m_PropertyItem = propertyItem;
        m_PasswordBox = new PasswordBox();
        m_PasswordBox.Password = (String)propertyItem.Value;
        m_PasswordBox.LostFocus += OnLostFocus; 
        return m_PasswordBox;

    void OnLostFocus(object sender, RoutedEventArgs e)
        if (0 != m_PasswordBox.Password.CompareTo((string)m_PropertyItem.Value))
            m_PropertyItem.Value = m_PasswordBox.Password;
Marked as answer by Toshpoint on 12/4/2013 at 7:33 PM
Mar 17, 2015 at 10:51 PM
Edited Mar 18, 2015 at 7:35 AM
I'm currently trying to use the provided PasswordEditor within my application (.NET 4.5.1, version 2.4.0 of the Toolkit library) but with no success. I'm using a wrapper class to hold the actual configuration settings. The wrapper contains all the annotations like Category, DisplayName and Description but with my own implementations to use resource files as string repositories. These attributes are currently working and showing fine within the PropertyGrid. For some reason the PasswordEditor is not shown in the PropertyGrid although I'm using the EditorAttributed as shown in the documentation.
[LocalizedDisplayName("ServerConfig", typeof(Resources.Strings.Resources))]
public class ServerConfigPropertyGrid
    #region fields
    private ServerConfig serverConfig;

    #region properties
    [LocalizedCategory("VeinStoreCategory", typeof(Resources.Strings.Resources))]
    [LocalizedDisplayName("ActiveDirectoryPasswordDisplayName", typeof(Resources.Strings.Resources))]
    [LocalizedDescription("ActiveDirectoryPasswordDescription", typeof(Resources.Strings.Resources))]
    [Editor(typeof(PasswordEditor), typeof(PasswordEditor))]
    public string LdapPassword
        get { return serverConfig.LdapPassword; }
        set { serverConfig.LdapPassword = value; }

    #region constructor
    public ServerConfigPropertyGrid(ServerConfig serverConfig)
        // store serverConfig
        this.serverConfig = serverConfig;
This is actually a shortened listing. Any idea what could cause this behavior?


Just found the solution myself. The WPF application includes a plugin architecture which loads all classes and their dependencies at runtime. It seems like there was somewhere an error while looking up the Xceed classes and therefore the default editors where used inside the PropertyGrid. So this was not a coding but rather a configuration mistake. Sorry guys for stealing your time.