打开VS2010,找到上次建立的Phone1项目。

<tk:ChildWindow
x:Class="PhoneApp1.Login.LoginPop"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:tk="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
mc:Ignorable="d" VerticalAlignment="Top" HorizontalAlignment="Left"
BorderBrush="Black" BorderThickness="2" HasCloseButton="False"
d:DesignHeight="256" d:DesignWidth="480" Title="看看呗" >
<!--LayoutRoot 是包含所有页面内容的根网格-->
<Grid x:Name="LayoutRoot" Height="202" Background="{StaticResource PhoneBackgroundBrush}">
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="用户名: " VerticalAlignment="Top" Margin="20,43,0,0"/>
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="密 码: " VerticalAlignment="Top" Margin="20,104,0,0"/>
<TextBox x:Name="txtUserId" VerticalAlignment="Top" Margin="117,23,8,0" Height="62" FontSize="18.667" TabIndex="1" >
<PasswordBox x:Name="txtPassword" VerticalAlignment="Top" Margin="117,85,8,0" Height="62" FontSize="18.667" TabIndex="2" />
<Button x:Name="btn_sub" Content="开门" Margin="117,132,214,0" d:LayoutOverrides="Width" FontSize="18.667" BorderBrush="{StaticResource PhoneAccentBrush}" BorderThickness="1" Foreground="{StaticResource PhoneForegroundBrush}" Background="{StaticResource PhoneInactiveBrush}" Height="58" VerticalAlignment="Top" FontFamily="Tahoma" TabIndex="3" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="252,146,0,0" Name="lbl_error" Text="" VerticalAlignment="Top" Width="184" />
</Grid>
</tk:ChildWindow> private void btn_login_Click(object sender, RoutedEventArgs e)
{
LoginPop login = new LoginPop();
login.Show();
} private void btnLogin_Click(object sender, RoutedEventArgs e)
{
if(txtUserId .Text .Trim ().Equals(""))
{
lbl_error.Text = "用户名不能为空!";
txtUserId.Text = "";
return;
}
if (txtPassword.Password.Trim().Equals(""))
{
lbl_error.Text = "密码不能为空!";
txtPassword.Password = "";
return;
}
}

2209



被折叠的 条评论
为什么被折叠?



