Welcome to Geeks Portal Sign in | Join | Help | Sign In Live ID
in
 
 

MAYA'S weB LOGS

Some random Silverlight 2.0 FAQ

Today FAQ sections from Silverlight 2.0 in my class conducted in Microsoft Singapore :


1.How to repeat video in Silverlight 2.0 in C# code?


in page.xaml:
<MediaElement x:Name="PapiChanVideo"
                          Margin="19,0,0,82"
                          VerticalAlignment="Bottom"
                          Source="Video/14FtWavesMexico.wmv" MediaEnded="PapiChanVideo_MediaEnded"
                          Stretch="Fill"
                          HorizontalAlignment="Left"
                          Height="146"
                          Width="238"/>


and the next step under C#
  private void PapiChanVideo_MediaEnded(object sender, RoutedEventArgs e)
        {
            PapiChanVideo.Stop();
            PapiChanVideo.Play();
        }

 

2. Is it possible to generate a Style in App.xaml without mentioning TargetType?
No.


3. What is the meaning of star in width="5*" or width="10*" while you define a rowdefinition?
This means that this is a relative value to the total height or width of the Grid that these belong to.
So if you have two rows and the first row has a height of 5* and the second row has a height of 10*,
then the Grid will try and keep the second row at twice the height of the first row, based on the available space
and the space requested by the controls in the rows.
If I would change the second row to 5* then the Grid will try to keep the rows at the same height.


4. How do we remove the column filler in a datagrid if we only have 2data columns but it looks like there are 3 columns generated?
So this is actually a column filler, because while you define a grid in absolute numbers it will generate a filler(so it will looks like 3
column eventhough you have only 2 columns).This sample code will generate column filler:

<StackPanel Orientation="Vertical">
                    <TextBlock Text="Horse Race Results" />
                    <myData:DataGrid x:Name="dgRaces"
                                     AutoGenerateColumns="False"
                                     Height="140"
                                     Width="220"
                                     BorderThickness="0">
                        <!-- DataGrid Column definitions go here -->
                        <myData:DataGrid.Columns>
                            <myData:DataGridTextColumn Binding="{Binding Place}" Header="Place" />
                            <myData:DataGridTextColumn Binding="{Binding HorseName}" Header="HorseName" />
                        </myData:DataGrid.Columns>
                    </myData:DataGrid>
                </StackPanel>

because in a data call Place and HorseName , we dont define the absolute number based on grid, so the next code will resolve the issue

       <StackPanel Orientation="Vertical">
                    <TextBlock Text="Horse Race Results" />
                    <myData:DataGrid x:Name="dgRaces"
                                     AutoGenerateColumns="False"
                                     Height="140"
                                     Width="220"
                                     BorderThickness="0">
                        <!-- DataGrid Column definitions go here -->
                        <myData:DataGrid.Columns>
                            <myData:DataGridTextColumn Binding="{Binding Place}" Header="Place" Width="100"  />
                            <myData:DataGridTextColumn Binding="{Binding HorseName}" Header="HorseName" Width="120"/>
                        </myData:DataGrid.Columns>
                    </myData:DataGrid>
                   
                </StackPanel>


(so we only need to add the absolute width in our data binding to make sure there are no filler for in the blank area of the grid)

 

 


 

Share this post: | | | |
Published Sep 15 2009, 03:24 PM by maya
Filed under:

Comments

 

zeddy said:

seru, kapan ngasih training di Jkt? :)

September 16, 2009 9:48 AM
 

maya said:

Jakarta udah punya Zeddy dan mr. Reza, gak usah ditraining lagih... x)

September 16, 2009 10:47 AM
 
 
Powered by Community Server (Commercial Edition), by Telligent Systems
Copyright © INDC, 2006. All rights reserved.