xaml页面
<Thumb Height="233" HorizontalAlignment="Stretch"Name="thumb1" VerticalAlignment="Stretch" Width="290"
DragDelta="thumb1_DragDelta" DragStarted="thumb1_DragStarted"DragCompleted="thumb1_DragCompleted"/>
cs页面
public partial class Thumb : PhoneApplicationPage
{
public Thumb()
{
InitializeComponent();
}
//移动中
private void thumb1_DragDelta(object sender,System.Windows.Controls.Primitives.DragDeltaEventArgs e)
{
this.PageTitle.Text =string.Format("x:{0},y:{1}",e.HorizontalChange,e.VerticalChange);
}
//开始
private void thumb1_DragStarted(object sender,System.Windows.Controls.Primitives.DragStartedEventArgs e)
{
this.PageTitle.Text = "started";
}
//完成
private void thumb1_DragCompleted(object sender,System.Windows.Controls.Primitives.DragCompletedEventArgs e)
{
this.PageTitle.Text = "completed";
}
}
------------------------------------------------------------------------------
这是第二个应用
xmal
<Thumb Height="233" HorizontalAlignment="Stretch"Name="thumb1" VerticalAlignment="Stretch" Width="290"
DragDelta="thumb1_DragDelta" DragStarted="thumb1_DragStarted"DragCompleted="thumb1_DragCompleted">
<Thumb.RenderTransform>
<TranslateTransformx:Name="tr"></TranslateTransform>
</Thumb.RenderTransform>
</Thumb>
cs:
//移动中
private void thumb1_DragDelta(object sender,System.Windows.Controls.Primitives.DragDeltaEventArgs e)
{
// this.PageTitle.Text =string.Format("x:{0},y:{1}",e.HorizontalChange,e.VerticalChange);
tr.X = tr.X + e.HorizontalChange;
tr.Y = tr.Y + e.VerticalChange;
}
开始事件 和完成事件 和上面一样了,这个就是thumb可以随意拖动
转载:http://laihuaiqing.iteye.com/blog/1299431