`

wp7 开发学习之 Thumb小应用

    博客分类:
  • WP7
阅读更多

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>
<TranslateTransform x: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可以随意拖动

分享到:
评论
发表评论

文章已被作者锁定,不允许评论。

相关推荐

Global site tag (gtag.js) - Google Analytics