Silverlight Carrousel實現(xiàn)界面布局
Silverlight開發(fā)工具的出現(xiàn)為我們帶來了全新的編程環(huán)境。那么,在使用這一工具進行開發(fā)的前提就是要良好的掌握各種內(nèi)置控件的使用。比如我們今天要為大家介紹的Silverlight Carrousel是一個布局控件,可對其內(nèi)部的子控件排出像《旋轉木馬》一樣的效果。#t#
Silverlight Carrousel使用:
在這里下載DLL文件,其中包含一個文件:CarrouselPanel.dll。下載了文件后在Silverlight項目中添加引用。
在page.xaml的頭部添加代碼
- xmlns:CarrouselPanel="
clr-namespace:Carrousel
Panel;assembly=CarrouselPanel"
把ScatterView控件放入page中
- < CarrouselPanel:CarrouselPanel
x:Name="xCarrouselPanel" Height=
"Auto" HorizontalAlignment=
"Stretch" VerticalAlignment=
"Stretch" Width="Auto"/>
在后臺添加子控件
- for (int i = 1; i < = 21; i++)
- {
- StreamResourceInfo sri =
Application.GetResourceStream
(new Uri("Carrousel;component/
img/" + i + ".jpg", UriKind.
Relative));- BitmapImage bi = new BitmapImage();
- bi.SetSource(sri.Stream);
- Image img = new Image();
- img.Source = bi;
- img.Width = 120;
- img.Height = 200;
- this.xCarrouselPanel.AddChild(img);
- }
Silverlight Carrousel的相關應用方法就為大家介紹到這里。