Silverlight做了两个布局的控件了。
Silverlight控件 - Carrousel Silverlight控件 - ScatterView
所有的东西都是由浅入深的做的,在做这两个控件的时候也摸索了不少东西。这里整理出一个最基本的布局控件:panel 的代码然后从这里出发构建自己的布局控件把。
代码语言:javascript复制using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace CarrouselPanel
{
public class CarrouselPanel : Panel
{
public CarrouselPanel()
: base()
{
}
protected override Size ArrangeOverride(Size finalSize)
{
foreach (UIElement element in base.Children)
{
Point location = new Point();
element.Arrange(new Rect(location, element.DesiredSize));
}
return finalSize;
}
protected override Size MeasureOverride(Size availableSize)
{
foreach (UIElement element in base.Children)
{
element.Measure(availableSize);
}
base.Clip = new RectangleGeometry { Rect = new Rect(new Point(), availableSize) };
return availableSize;
}
}
}