我正在尝试制作自定义组件但需要帮助。
private string _passwordText;
public string PasswordText
{
get
{
_passwordText = passwordB.Password;
return _passwordText;
}
set
{
SetProperty<string>(ref _passwordText, value, "PasswordText");
passwordB.Password = _passwordText;
passwordB_PasswordChanged(passwordB, null);
}
}
public event PropertyChangedEventHandler PropertyChanged;
private bool SetProperty<T>(ref T storage, T value, [CallerMemberName] String propertyName = null)
{
if (Equals(storage, value)) return false;
storage = value;
OnPropertyChanged(propertyName);
return true;
}
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
AkbankStoreApp.exe中出现“Windows.UI.Xaml.Markup.XamlParseException”类型的异常,但未在用户代码中处理
WinRT信息:无法分配给属性'Windows8.StoreApp.Common.CustomControls.WatermarkPasswordTextBox.PasswordText'。 [行:51位置:26]
答案 0 :(得分:1)
你有OnApplyTemplate覆盖吗?密码B来自哪里?如果是这样,您可能需要在为其属性赋值之前检查passwordB是否为null。请查看this以供参考。