设置Popup.Child导致HRESULT E_FAIL

时间:2010-09-17 22:24:58

标签: silverlight silverlight-4.0

我正在尝试为PasswordBox实施一个加法器来添加水印功能。我基于http://sladorner.codeplex.com/的项目。我已经在沙盒应用程序中使用了水印实现,但是当我尝试将其添加到类库时,我遇到了问题。

当执行设置_Popup.Child的行时,我得到异常“错误HRESULT E_FAIL已从调用COM组件返回。”有没有解决方案(或者可能是一个完全不同的方法围绕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;
    }

0 个答案:

没有答案