31 August 2009

wpf Grid rows and columns


  • Open xmal file and write below code

    <Grid>

    <Grid.RowDefinitions>

    <RowDefinition Height="Auto"/>

    <RowDefinition Height="Auto"/>

    <RowDefinition Height="*"/>

    <RowDefinition Height="28"/>


    </Grid.RowDefinitions>

    <Grid.ColumnDefinitions>

    <ColumnDefinition Width="Auto"/>

    <ColumnDefinition Width="*"/>

    </Grid.ColumnDefinitions>

    <Label Content="Name :" Grid.Column="0" Grid.Row="0"/>

    <Label Content="Email :" Grid.Column="0" Grid.Row="1"/>

    <Label Content="Comment :" Grid.Row="2" Grid.Column="0"/>

    <TextBox Margin="3" FontFamily="Garamond" Grid.Column="1" Grid.Row="0" />

    <TextBox Grid.Column="1" Grid.Row="1" FontStyle="Italic" Margin="3" />

    <TextBox Grid.Column="1" Grid.Row="2" FontFamily="Garamond" FontSize="18" Foreground="Blue" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" Margin="3" />

    <Button Grid.Column="1" Grid.Row="3" Margin="3" MaxWidth="100" Content="Send"/>

    </Grid>

  • Execute the program.

24 August 2009

Activate Windows 7

  • To activate windows 7 go through below given steps
  • Open Control panel --> System
  • In the Windows Activation section click on change product key
  • Enter following key 'Q3VMJ-TMJ3M-99RF9-CVPJ3-Q7VF3'
  • Press Enter (Make sure your internet connection is on)
  • It will activate your windows..

22 August 2009

Styles in Wpf


  1. Open Visual Studio 2008
  2. New WPF windows application
  3. Open window1.xaml file
  4. Write below given code above <Grid>


<Window.Resources>


<Style x:Key="mystyle" TargetType="Button">


<Setter Property="Background" Value="Orange"/>


<Setter Property="FontStyle" Value="Italic"/>


<Setter Property="Padding" Value="8,4"/>


<Setter Property="Margin" Value="4"/>


</Style>


</Window.Resources>

  1. Write below code between <Grid>… …</Grid>


<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"
VerticalAlignment="Center">


<Button Style="{StaticResource mystyle}" Content="Vijay"/>


<Button Style="{StaticResource mystyle}" Content="Raju"/>


<Button Style="{StaticResource mystyle}" Content="Mygo"/>


</StackPanel>

  1. Execute the program..

21 August 2009

Apply gradients to controls in wpf



  • Open wpf application template
  • Write code as below

</Window>

<Window.Background>

<LinearGradientBrush>
<GradientStop Color="blue" Offset="0.2"/>

<GradientStop Color="Yellow" Offset="0.6"/>

<GradientStop Color="Orange" Offset="0.8"/>

</LinearGradientBrush>

</Window.Background>

<Grid>

<Button Content="Click" Width="200" Height="50">

<Button.Background>

<RadialGradientBrush>

<GradientStop Color="Violet"
Offset="0.9"/>

<GradientStop Color="red" Offset="0.1"/>

<GradientStop Color="Yellow" Offset="0.5"/>

<GradientStop Color="Pink" Offset="0.99"/>

</RadialGradientBrush>

</Button.Background>

</Button>

</Grid>

</Window>

  • Now Execute the project by clicking the F5

wpf application with colourfull backgrounds

· Open Visual Studio 2008

· Select Windows WPF Application Template

· It will open new empty widow

· Click on ‘Window.xaml’ file

· Write below given code between the <window> .. .. .. </window> tag

<Window.Background>

<LinearGradientBrush>

<GradientStop Color="Violet" Offset="0.9"/>

<GradientStop Color="red" Offset="0.1"/>

<GradientStop Color="Yellow" Offset="0.5"/>

<GradientStop Color="Pink" Offset="0.99"/>

</LinearGradientBrush>

</Window.Background>

· Now execute the program..

· The output will be shown as above..

· Now change the code between the as below

<Window.Background>

<RadialGradientBrush>

<GradientStop Color="blue" Offset="0.2"/>

<GradientStop Color="Yellow" Offset="0.6"/>

<GradientStop Color="Orange" Offset="0.8"/>

</RadialGradientBrush

</Window.Background>

· Now again execute the program..

· It will be shown below window



13 August 2009

Clear all text boxes by one click in same field..

  • This program for the child webpage of the masterpage..
  • It is the masterpage concept

    ContentPlaceHolder content1 = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
    foreach(Control ctrl in content1.Controls)
    {

    if (ctrl.GetType().ToString() == "System.Web.UI.WebControls.Panel")
    {
    foreach (Control ctr in Panel1.Controls)
    {
    if (ctr.GetType().ToString() =="System.Web.UI.WebControls.TextBox")
    ((TextBox)ctr).Text = string.Empty;
    }
    }
    }