Make your Windows application a more animated and colorful attraction.
Use the following procedure.
- Open Visual Studio. (Here I used Visual Studio 2012).
- Go to New project then select WPF application as shown in the figure.
- Now go to Solution Explorer and add a new folder as shown in the figure.
- Provide it the “Images”.
- Add the entire image to this folder. (Here the image is given in the scours code demo project).
- Add a new window to the project and give it the name “login2.xaml”.
- Now open “login2.xaml” and write the code for displaying the images.
- Set the main window properties.
- <Window x:Class="LoginFormInWPF.login2"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- Title="login2" Height="700" Width="400" AllowsTransparency="True" WindowStyle="None" WindowStartupLocation="CenterScreen">
- Now add a background image display in the code.
- <Window.Background>
- <ImageBrush ImageSource="Images/Untitled-1.png"/>
- </Window.Background>
- Now add other code for displaying the validation of images, textboxes, login button and so on.
- <Grid>
- <TextBox HorizontalAlignment="Left" Height="30" Margin="135,313,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="169"/>
- <Button Content="" HorizontalAlignment="Left" Margin="248,410,0,0" VerticalAlignment="Top" Width="54" Height="24" Click="Button_Click_1">
- <Button.Background>
- <ImageBrush/>
- </Button.Background>
- </Button>
- <Image HorizontalAlignment="Left" Source="Images/worng.png" Height="30" VerticalAlignment="Top" Width="41" Margin="309,313,0,0">
-
- </Image>
- <Image HorizontalAlignment="Left" Source="Images/Warning.png" Height="30" VerticalAlignment="Top" Width="41" Margin="309,361,0,0"/>
- <PasswordBox HorizontalAlignment="Left" Margin="135,361,0,0" VerticalAlignment="Top" Width="169" Height="30"/>
- <Image HorizontalAlignment="Left" Height="25" VerticalAlignment="Top" Width="30" Margin="368,6,0,0" Source="Images/close.png" MouseDown="Image_MouseDown_1"/>
- <Image HorizontalAlignment="Left" Height="25" VerticalAlignment="Top" Width="30" Margin="336,6,0,0" Source="Images/minimize.png" MouseDown="Image_MouseDown_2"/>
- </Grid>
Now open in App.xamp and change the startup form name like:
Here this open the Login2.xaml form when you run the project.
- Now run your projects. It will show the output such as you shown in the preceding image. If you have any query then provideit in the comments section.