Wednesday, October 22, 2014

Grid Layout in Windows Presentation Foundation (WPF)

It is fresh code after create new Item Window in WPF Project.


    
        
    

Setup Row in Grid Layout
We can setup our layout of windows based on ROW oriented. We will control height of row. There are 4 types of height value,

  1. 'Auto'
  2. '*' 
  3. Comparison Value
  4. Numeric Value


"Auto"  is used to define height of layout based on highest component inside container.
"*" is used to define height of layout rest of space container sibling.
Comparison Value is used to define height of layout based on comparison value with sibling. Numeric Value is used to define height of layout based on fixed value that declared using numeric.



Code:
<Window x:Class="WPF01.Layout.LearnGrid"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="LearnGrid" Height="300" Width="300">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="50" />
        </Grid.RowDefinitions>
        
        <Grid Grid.Row="0" Background="Red">
            <Label Content="Row Height is Auto, based on height of this lable"/>
        </Grid>
        
        <Grid Grid.Row="1" Background="Green">
            <Label Content="Row Height '*' is rest of space siblings height" />
        </Grid>
        
        <Grid Grid.Row="2" Background="Yellow">
            <Label Content="Row Height is 50 pixels" />
        </Grid>
    </Grid>
</Window>





Setup Column in Grid Layout

Membuat Project Windows Presentation Foundation (WPF)

Dalam posting kali ini saya akan menjelaskan tentang pembuatan project Windows Presentation Foundation (WPF).
Tools: Visual Studio 2013 Express for Windows
Language: C#
Tahapan Membuat Project:

  1. Pilih menu: File > New Project. Tampil jendela New Project
  2. Templates > Visual C# > WPF Application
  3. Tentukan Project Name dan Location
  4. Ok
  5. Tekan F5 untuk menjalankan program atau melalu menu Debug > Start Debuging

Jendela New Project



Hello World

It's first time I write a code in my blog.

public static void main(string whatever[])
{
  Console.WriteLine("Hello World");
}