Silverlight Carrousel实现界面布局

Silverlight开发工具的出现为我们带来了全新的编程环境。那么,在使用这一工具进行开发的前提就是要良好的掌握各种内置控件的使用。比如我们今天要为大家介绍的Silverlight Carrousel是一个布局控件,可对其内部的子控件排出像《旋转木马》一样的效果。#t#

Silverlight Carrousel使用:

在这里下载DLL文件,其中包含一个文件:CarrouselPanel.dll。下载了文件后在Silverlight项目中添加引用。
在page.xaml的头部添加代码

  1. xmlns:CarrouselPanel="
    clr-namespace:Carrousel
    Panel;assembly=CarrouselPanel"
      

把ScatterView控件放入page中

 
 
 
  1. < CarrouselPanel:CarrouselPanel 
    x:Name="xCarrouselPanel" Height=
    "Auto" HorizontalAlignment=
    "Stretch" VerticalAlignment=
    "Stretch" Width="Auto"/> 

在后台添加子控件

 
 
 
  1. for (int i = 1; i < = 21; i++)  
  2. {  
  3. StreamResourceInfo sri = 
    Application.GetResourceStream
    (new Uri("Carrousel;component/
    img/" + i + ".jpg", UriKind.
    Relative));  
  4. BitmapImage bi = new BitmapImage();  
  5. bi.SetSource(sri.Stream);  
  6. Image img = new Image();  
  7. img.Source = bi;  
  8. img.Width = 120;  
  9. img.Height = 200;  
  10. this.xCarrouselPanel.AddChild(img);  
  11. }  

Silverlight Carrousel的相关应用方法就为大家介绍到这里。

THE END