Set Layout in Silverlight

Hiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii


Set the Layout for controls in Silverlight

As we all know silverlight  doesnot provide the facilty for dragging n dropping controls as we do in asp application

In VS 2008 we can only see the design vioew but it doesnot allow us to drag controls All we have to do manually in xaml file


By default the layout is 'flow layot' means controls are placed one after another

To customize it chk the below code written in xaml file

<UserControl x:Class="SilverlightApplication.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
  <Grid x:Name="LayoutRoot">
        <Grid Background="Bisque" Width="500" Height="500" >
            <Grid.RowDefinitions>
                <RowDefinition Height="50"></RowDefinition>
                <RowDefinition Height="100"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="250"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Button Content="Push" Grid.Row="0" Grid.Column="1"></Button>
           
      
            <ListBox Grid.Row="1" Grid.Column="0"  SelectedItem="0" >
                 <ListBoxItem  Content="Tea" ></ListBoxItem>
                <ListBoxItem  Content="Coffee" ></ListBoxItem>
                <ListBoxItem  Content="Milk Shake" ></ListBoxItem>
                <ListBoxItem  Content="Cold drink" ></ListBoxItem>
                <ListBoxItem  Content="Hot Coffee" ></ListBoxItem>
                <ListBoxItem  Content="Kasata" ></ListBoxItem>
             </ListBox>

          
                </Grid>
        </Grid>
</UserControl>
snapshot.JPG

In the above example der i have a grid layout which is having 3 Rows and Each Row have 2 Columns
means 3*2 matrix


Ebook Download
View all
Learn
View all