【发布时间】:2014-12-06 10:11:07
【问题描述】:
我有这段代码(问题行上面有 cmets):
private async void btn_loginAdmin_Click(object sender, RoutedEventArgs e)
{
// 'txt_adminId' does not exist in the current context.
if (txt_adminId.Text = "root")
{
// 'txt_adminPw' does not exist in the current context.
if (txt_adminPw.Password = "password")
{
var msg_login = new MessageDialog("Logged in!");
await msg_login.ShowAsync();
}
else
{
var msg_login = new MessageDialog("Wrong password!");
await msg_login.ShowAsync();
}
}
else
{
var msg_login = new MessageDialog("Wrong combo!");
await msg_login.ShowAsync();
}
}
我一直有 C# 的这个问题。我不知道这意味着什么。但我确信在这个文件的 .xaml 中,存在这两个文本框。
- 这是一个 Windows 应用商店 C# 程序。
编辑:
这是输出:
1>C:\Database\GH3_WSE\GH3_WSE\login_admin.xaml.cs(119,17,119,42): error CS0029: Cannot implicitly convert type 'string' to 'bool'
1>C:\Database\GH3_WSE\GH3_WSE\login_admin.xaml.cs(121,21,121,54): error CS0029: Cannot implicitly convert type 'string' to 'bool'
【问题讨论】:
-
为什么您的 Click 处理程序被标记为异步?
-
使 MessageDialog 工作。我尝试删除它们,但没有解决问题。
-
我明白了。没有使用 WP 的经验,但在我看来与异步和线程有关。在这里使用 MVVM 可能会对您有所帮助。
-
我听到很多。但我不知道如何开始。
-
@Wix 你确定你有一张有效的支票
txt_adminId.Text = "root"吗?不应该是==吗?在这条线上同样if (txt_adminPw.Password = "password")