Reuse the userControl which takes the user name and password.
1. Create new project in WPF(I named the project UserControlSample).
2. Add a new user control to that project (Right Click and Add -> User Control). Since my user control takes user name and password I renamed my user control as RegisterUserControl.
3. Add two labels two text boxes RegisterUserControl.
RegisterUserControl.xaml
<Window x:Class="UserControlSample.RegisterWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:UserControlSample"
Title="RegisterWindow"
Height="400"
Width="400"
Loaded="
Window_Loaded">
<Grid>
<local:RegisterUserControl
Margin="0,-21,40,21"
Height="268">
</local:RegisterUserControl>
<Button Content="Button"
Height="23"
HorizontalAlignment="Left"
Margin="208,256,0,0"
Name="Login"
VerticalAlignment="Top"
Width="75" />
</Grid>
</Window>
The RegistrationWindow uses the RegisterUserControl to add User name and password to it.
RegisterWindow.xaml
<UserControl x:Class="UserControlSample.RegisterUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Label Content="UserName"
Height="28"
HorizontalAlignment="Left"
Margin="28,63,0,0"
Name="label1"
VerticalAlignment="Top"
Width="77" />
<Label Content="Password"
Height="28"
HorizontalAlignment="Left"
Margin="28,112,0,0"
Name="label2"
VerticalAlignment="Top"
Width="77" />
<TextBox Height="28"
HorizontalAlignment="Left"
Margin="140,63,0,0"
Name="UsernameTextBox"
VerticalAlignment="Top"
Width="120" />
<TextBox Height="28"
HorizontalAlignment="Left"
Margin="140,112,0,0"
Name="PasswordTextBox"
VerticalAlignment="Top"
Width="120" />
</Grid>
</UserControl>
I also added a login button to our main RegisterWindow.
0 comments:
Post a Comment