One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man

Friday, July 1, 2011

WPF transparent form application

1) First you have to create a new WPF application project
                                           File -> New -> project
select WPF application and press OK

2) Then you have to create a circle inside the form using the Ellipse tool in the toolbox
3) After that you have to do few changes to the XAML coding


Your  coding appear like the following


<Window x:Class="MyApp.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <Grid>
        <Ellipse Margin="-1,-1,-1,1" Name="ellipse1" Stroke="Black"/>
    </Grid>
</Window>


That must change like following


<Window x:Class="MyApp.Window1" MouseLeftButtonDown="Window_MouseLeftButtonDown" WindowStyle="None" AllowsTransparency="True" Background="Transparent"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <Grid>
        <Ellipse Margin="-1,-1,-1,1" Name="ellipse1" Stroke="Black" Fill="Gray" Opacity="0.5"/>
        <Button Height="23" Margin="99,28,104,0" Name="button1" VerticalAlignment="Top">Close</Button>
    </Grid>
</Window>


following picture show you the changes by underlining newly added parts
4) Then double click on the button and write the following coding part
               Close();
5) Then write the following code inside the "Window_MouseLeftButtonDown" method
               DragMove();
   You can see the above 2 steps from the picture
6) Finally build the solution and see the result. you can drag the form by draging the content of the form
This is a very basic WPF form application. You can develop any complex interfaces or application same as the normal windows form application by using this theory

5 comments:

  1. hey plz tell me that the login page hw to creat it nice n attractive plzz. i want my all form looking nic n attractiv how to do that?

    ReplyDelete
    Replies
    1. 1) When you create it take rectangle and round corners
      2) Use Attractive color and make it 90% transparent
      3) When you create other forms change XML according to the login page XML (you can also copy xml and change size and all that)
      4) Use expression blender when you are creating UI s
      5) Then open it in visual studio 2010 (highly compatible with XML)
      6) Then code the logic
      7) Enjoy it... Contratz

      Delete
  2. 1) When you create it take rectangle and round corners
    2) Use Attractive color and make it 90% transparent
    3) When you create other forms change XML according to the login page XML (you can also copy xml and change size and all that)
    4) Use expression blender when you are creating UI s
    5) Then open it in visual studio 2010 (highly compatible with XML)
    6) Then code the logic
    7) Enjoy it... Contratz

    ReplyDelete