views:

37

answers:

0

I'm attempting to implement an adorner for a PasswordBox to add watermark functionality. I'm basing it on the project at http://sladorner.codeplex.com/. I've gotten the watermark implementation working in a sandbox application, but I'm running into issues when I attempt to add this to a class library.

When the line that sets _Popup.Child is executed, I get the exception "Error HRESULT E_FAIL has been returned from a call to a COM component." Is there a solution for this (or maybe a completely different way around the issue of watermarking a PasswordBox)?

public class PasswordBoxWatermarkAdorner : Control
{
    private Border _ContentBorder;
    private TextBlock _WatermarkTextBlock;
    private PasswordBox _AssociatedElement;
    private Popup _Popup;
    private string _WatermarkText;

    public PasswordBoxWatermarkAdorner(PasswordBox associatedElement, string watermarkText)
    {
        this.DefaultStyleKey = typeof(PasswordBoxWatermarkAdorner);
        _AssociatedElement = associatedElement;
        _WatermarkText = watermarkText;

        _Popup = new Popup
        {
            Child = this,
            IsOpen = true
        };

        _Popup.LayoutUpdated += _Popup_LayoutUpdated;
    }