Windows phone中最常用的控件是TextBlock、TextBox和Button。TextBlock用来显示信息,TextBox一般用来输入信息,Button用来相应点击事件。但是不绝对是这样的,为什么呢,因为silverlight最强大的地方在于模板,只要你定义合适的模板,那TextBlock可以作为一个TextBox使用也可以作为一个Button使用。关于模板的内容在以后的章节中描述,现在是要知道,silverlight可以千变万化就好了,windows phone 7SDK是基于silverlight3的,7.1SDK是基于silvelight4的所以windows phone的控件也是千变万化的。

看一下TextBlock的属性、方法与事件

属性


             名称 说明
ActualHeight FrameworkElement。)
ActualWidth FrameworkElement。)
AllowDrop UIElement。)
AreAnyTouchesCaptured UIElement。)
AreAnyTouchesCapturedWithin UIElement。)
AreAnyTouchesDirectlyOver UIElement。)
AreAnyTouchesOver UIElement。)
Background Brush
BaselineOffset 获取或设置每个文本行相对于基线的偏移量。
BindingGroup FrameworkElement。)
BitmapEffect 已过时。UIElement。)
BitmapEffectInput 已过时。UIElement。)
BreakAfter LineBreakCondition,它指示内容应当如何在当前元素之后进行分行。
BreakBefore LineBreakCondition,它指示内容应当如何在当前元素之前进行分行。
CacheMode UIElement。)
Clip UIElement。)
ClipToBounds UIElement。)
CommandBindings UIElement。)
ContentEnd TextPointer
ContentStart TextPointer
ContextMenu FrameworkElement。)
Cursor FrameworkElement。)
DataContext FrameworkElement。)
DefaultStyleKey FrameworkElement。)
DependencyObjectType DependencyObject。)
DesiredSize UIElement。)
Dispatcher DispatcherObject。)
Effect UIElement。)
FlowDirection FrameworkElement。)
Focusable UIElement。)
FocusVisualStyle FrameworkElement。)
FontFamily TextBlock 的首选顶级字体系列。
FontSize TextBlock 的顶级字号。
FontStretch TextBlock 的顶级字体拉伸特征。
FontStyle TextBlock 的顶级字形。
FontWeight TextBlock 的顶级字体粗细。
ForceCursor FrameworkElement。)
Foreground Brush
HasAnimatedProperties UIElement。)
Height FrameworkElement。)
HorizontalAlignment FrameworkElement。)
HostedElementsCore TextBlock 承载的元素的枚举数。
InheritanceBehavior FrameworkElement。)
Inlines Inline 元素。
InputBindings UIElement。)
InputScope FrameworkElement。)
IsArrangeValid UIElement。)
IsEnabled UIElement。)
IsEnabledCore UIElement。)
IsFocused UIElement。)
IsHitTestVisible UIElement。)
IsHyphenationEnabled 获取或设置一个值,该值指示是否启用文字的自动断字功能。
IsInitialized FrameworkElement。)
IsInputMethodEnabled UIElement。)
IsKeyboardFocused UIElement。)
IsKeyboardFocusWithin UIElement。)
IsLoaded FrameworkElement。)
IsManipulationEnabled UIElement。)
IsMeasureValid UIElement。)
IsMouseCaptured UIElement。)
IsMouseCaptureWithin UIElement。)
IsMouseDirectlyOver UIElement。)
IsMouseOver UIElement。)
IsSealed DependencyObject。)
IsStylusCaptured UIElement。)
IsStylusCaptureWithin UIElement。)
IsStylusDirectlyOver UIElement。)
IsStylusOver UIElement。)
IsVisible UIElement。)
Language FrameworkElement。)
LayoutTransform FrameworkElement。)
LineHeight 获取或设置各行内容的高度。
LineStackingStrategy TextBlock 内的每行文本确定行框的机制。
LogicalChildren FrameworkElement.LogicalChildren。)
Margin FrameworkElement。)
MaxHeight FrameworkElement。)
MaxWidth FrameworkElement。)
MinHeight FrameworkElement。)
MinWidth FrameworkElement。)
Name FrameworkElement。)
Opacity UIElement。)
OpacityMask UIElement。)
OverridesDefaultStyle FrameworkElement。)
Padding TextBlock 所显示内容之间的边距的宽度。
Parent FrameworkElement。)
PersistId 已过时。UIElement。)
RenderSize UIElement。)
RenderTransform UIElement。)
RenderTransformOrigin UIElement。)
Resources FrameworkElement。)
SnapsToDevicePixels UIElement。)
Style FrameworkElement。)
StylusPlugIns UIElement。)
Tag FrameworkElement。)
TemplatedParent FrameworkElement。)
Text TextBlock 的文本内容。
TextAlignment 获取或设置一个值,该值指示文本内容的水平对齐方式。
TextDecorations TextBlock 的文本的效果。
TextEffects 获取或设置要应用于此元素中的文本内容的效果。
TextTrimming 获取或设置当内容溢出内容区域时要采取的文本修整行为。
TextWrapping TextBlock 对文本进行换行的方式。
ToolTip FrameworkElement。)
TouchesCaptured UIElement。)
TouchesCapturedWithin UIElement。)
TouchesDirectlyOver UIElement。)
TouchesOver UIElement。)
Triggers FrameworkElement。)
Typography 获取此元素的内容的当前有效版式变体。
Uid UIElement。)
UseLayoutRounding FrameworkElement。)
VerticalAlignment FrameworkElement。)
Visibility UIElement。)
VisualBitmapEffect 已过时。Visual。)
VisualBitmapEffectInput 已过时。Visual。)
VisualBitmapScalingMode Visual。)
VisualCacheMode Visual。)
VisualChildrenCount FrameworkElement.VisualChildrenCount。)
VisualClearTypeHint Visual。)
VisualClip Visual。)
VisualEdgeMode Visual。)
VisualEffect Visual。)
VisualOffset Visual。)
VisualOpacity Visual。)
VisualOpacityMask Visual。)
VisualParent Visual。)
VisualScrollableAreaClip Visual。)
VisualTextHintingMode Visual。)
VisualTextRenderingMode Visual。)
VisualTransform Visual。)
VisualXSnappingGuidelines Visual。)
VisualYSnappingGuidelines Visual。)
Width FrameworkElement。)
             名称 说明
AddHandler(RoutedEvent, Delegate) UIElement。)
AddHandler(RoutedEvent, Delegate, Boolean) UIElement。)
AddLogicalChild FrameworkElement。)
AddToEventRoute UIElement。)
AddVisualChild Visual。)
ApplyAnimationClock(DependencyProperty, AnimationClock) UIElement。)
ApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior) UIElement。)
ApplyTemplate FrameworkElement。)
Arrange UIElement。)
ArrangeCore FrameworkElement。)
ArrangeOverride FrameworkElement.ArrangeOverride(Size)。)
BeginAnimation(DependencyProperty, AnimationTimeline) UIElement。)
BeginAnimation(DependencyProperty, AnimationTimeline, HandoffBehavior) UIElement。)
BeginInit FrameworkElement。)
BeginStoryboard(Storyboard) FrameworkElement。)
BeginStoryboard(Storyboard, HandoffBehavior) FrameworkElement。)
BeginStoryboard(Storyboard, HandoffBehavior, Boolean) FrameworkElement。)
BringIntoView FrameworkElement。)
BringIntoView(Rect) FrameworkElement。)
CaptureMouse UIElement。)
CaptureStylus UIElement。)
CaptureTouch UIElement。)
CheckAccess DispatcherObject。)
ClearValue(DependencyProperty) DependencyObject。)
ClearValue(DependencyPropertyKey) DependencyObject。)
CoerceValue DependencyObject。)
EndInit FrameworkElement。)
Equals DependencyObject。)
Finalize Object。)
FindCommonVisualAncestor Visual。)
FindName FrameworkElement。)
FindResource FrameworkElement。)
Focus UIElement。)
GetAnimationBaseValue UIElement。)
GetBaselineOffset BaselineOffset 附加属性的值。
GetBindingExpression FrameworkElement。)
GetFontFamily FontFamilyProperty 附加属性的值。
GetFontSize FontSize 附加属性的值。
GetFontStretch FontStretch 附加属性的值。
GetFontStyle FontStyle 附加属性的值。
GetFontWeight FontWeight 附加属性的值。
GetForeground Foreground 附加属性的值。
GetHashCode DependencyObject。)
GetLayoutClip FrameworkElement。)
GetLineHeight LineHeight 附加属性的值。
GetLineStackingStrategy LineStackingStrategy 附加属性的值。
GetLocalValueEnumerator DependencyObject。)
GetPositionFromPoint TextPointer
GetRectanglesCore ContentElement 的边框的只读集合。
GetTemplateChild FrameworkElement。)
GetTextAlignment TextAlignment 附加属性的值。
GetType Object。)
GetUIParentCore FrameworkElement。)
GetValue DependencyObject。)
GetVisualChild FrameworkElement.GetVisualChild(Int32)。)
HitTestCore(GeometryHitTestParameters) UIElement。)
HitTestCore(PointHitTestParameters) UIElement.HitTestCore(PointHitTestParameters)。)
InputHitTest UIElement。)
InputHitTestCore IInputElement
InvalidateArrange UIElement。)
InvalidateMeasure UIElement。)
InvalidateProperty DependencyObject。)
InvalidateVisual UIElement。)
IsAncestorOf Visual。)
IsDescendantOf Visual。)
Measure UIElement。)
MeasureCore FrameworkElement。)
MeasureOverride FrameworkElement.MeasureOverride(Size)。)
MemberwiseClone Object。)
MoveFocus FrameworkElement。)
OnAccessKey UIElement。)
OnApplyTemplate FrameworkElement。)
OnChildDesiredSizeChanged UIElement。)
OnChildDesiredSizeChangedCore DesiredSize 时调用。
OnContextMenuClosing FrameworkElement。)
OnContextMenuOpening FrameworkElement。)
OnCreateAutomationPeer UIElement.OnCreateAutomationPeer。)
OnDragEnter UIElement。)
OnDragLeave UIElement。)
OnDragOver UIElement。)
OnDrop UIElement。)
OnGiveFeedback UIElement。)
OnGotFocus FrameworkElement。)
OnGotKeyboardFocus UIElement。)
OnGotMouseCapture UIElement。)
OnGotStylusCapture UIElement。)
OnGotTouchCapture UIElement。)
OnInitialized FrameworkElement。)
OnIsKeyboardFocusedChanged UIElement。)
OnIsKeyboardFocusWithinChanged UIElement。)
OnIsMouseCapturedChanged UIElement。)
OnIsMouseCaptureWithinChanged UIElement。)
OnIsMouseDirectlyOverChanged UIElement。)
OnIsStylusCapturedChanged UIElement。)
OnIsStylusCaptureWithinChanged UIElement。)
OnIsStylusDirectlyOverChanged UIElement。)
OnKeyDown UIElement。)
OnKeyUp UIElement。)
OnLostFocus UIElement。)
OnLostKeyboardFocus UIElement。)
OnLostMouseCapture UIElement。)
OnLostStylusCapture UIElement。)
OnLostTouchCapture UIElement。)
OnManipulationBoundaryFeedback UIElement。)
OnManipulationCompleted UIElement。)
OnManipulationDelta UIElement。)
OnManipulationInertiaStarting UIElement。)
OnManipulationStarted UIElement。)
OnManipulationStarting UIElement。)
OnMouseDown UIElement。)
OnMouseEnter UIElement。)
OnMouseLeave UIElement。)
OnMouseLeftButtonDown UIElement。)
OnMouseLeftButtonUp UIElement。)
OnMouseMove UIElement。)
OnMouseRightButtonDown UIElement。)
OnMouseRightButtonUp UIElement。)
OnMouseUp UIElement。)
OnMouseWheel UIElement。)
OnPreviewDragEnter UIElement。)
OnPreviewDragLeave UIElement。)
OnPreviewDragOver UIElement。)
OnPreviewDrop UIElement。)
OnPreviewGiveFeedback UIElement。)
OnPreviewGotKeyboardFocus UIElement。)
OnPreviewKeyDown UIElement。)
OnPreviewKeyUp UIElement。)
OnPreviewLostKeyboardFocus UIElement。)
OnPreviewMouseDown UIElement。)
OnPreviewMouseLeftButtonDown UIElement。)
OnPreviewMouseLeftButtonUp UIElement。)
OnPreviewMouseMove UIElement。)
OnPreviewMouseRightButtonDown UIElement。)
OnPreviewMouseRightButtonUp UIElement。)
OnPreviewMouseUp UIElement。)
OnPreviewMouseWheel UIElement。)
OnPreviewQueryContinueDrag UIElement。)
OnPreviewStylusButtonDown UIElement。)
OnPreviewStylusButtonUp UIElement。)
OnPreviewStylusDown UIElement。)
OnPreviewStylusInAirMove UIElement。)
OnPreviewStylusInRange UIElement。)
OnPreviewStylusMove UIElement。)
OnPreviewStylusOutOfRange UIElement。)
OnPreviewStylusSystemGesture UIElement。)
OnPreviewStylusUp UIElement。)
OnPreviewTextInput UIElement。)
OnPreviewTouchDown UIElement。)
OnPreviewTouchMove UIElement。)
OnPreviewTouchUp UIElement。)
OnPropertyChanged FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs)。)
OnQueryContinueDrag UIElement。)
OnQueryCursor UIElement。)
OnRender UIElement.OnRender(DrawingContext)。)
OnRenderSizeChanged FrameworkElement。)
OnStyleChanged FrameworkElement。)
OnStylusButtonDown UIElement。)
OnStylusButtonUp UIElement。)
OnStylusDown UIElement。)
OnStylusEnter UIElement。)
OnStylusInAirMove UIElement。)
OnStylusInRange UIElement。)
OnStylusLeave UIElement。)
OnStylusMove UIElement。)
OnStylusOutOfRange UIElement。)
OnStylusSystemGesture UIElement。)
OnStylusUp UIElement。)
OnTextInput UIElement。)
OnToolTipClosing FrameworkElement。)
OnToolTipOpening FrameworkElement。)
OnTouchDown UIElement。)
OnTouchEnter UIElement。)
OnTouchLeave UIElement。)
OnTouchMove UIElement。)
OnTouchUp UIElement。)
OnVisualChildrenChanged Visual。)
OnVisualParentChanged FrameworkElement。)
ParentLayoutInvalidated FrameworkElement。)
PointFromScreen Visual。)
PointToScreen Visual。)
PredictFocus FrameworkElement。)
RaiseEvent UIElement。)
ReadLocalValue DependencyObject。)
RegisterName FrameworkElement。)
ReleaseAllTouchCaptures UIElement。)
ReleaseMouseCapture UIElement。)
ReleaseStylusCapture UIElement。)
ReleaseTouchCapture UIElement。)
RemoveHandler UIElement。)
RemoveLogicalChild FrameworkElement。)
RemoveVisualChild Visual。)
SetBaselineOffset BaselineOffset 附加属性的值。
SetBinding(DependencyProperty, String) FrameworkElement。)
SetBinding(DependencyProperty, BindingBase) FrameworkElement。)
SetCurrentValue DependencyObject。)
SetFontFamily FontFamily 附加属性的值。
SetFontSize FontSize 附加属性的值。
SetFontStretch FontStretch 附加属性的值。
SetFontStyle FontStyle 附加属性的值。
SetFontWeight FontWeight 附加属性的值。
SetForeground Foreground 附加属性的值。
SetLineHeight LineHeight 附加属性的值。
SetLineStackingStrategy LineStackingStrategy 附加属性的值。
SetResourceReference FrameworkElement。)
SetTextAlignment TextAlignment 附加属性的值。
SetValue(DependencyProperty, Object) DependencyObject。)
SetValue(DependencyPropertyKey, Object) DependencyObject。)
ShouldSerializeBaselineOffset BaselineOffset 属性的有效值进行序列化。
ShouldSerializeCommandBindings UIElement。)
ShouldSerializeInlines Inlines 属性的有效值进行序列化。
ShouldSerializeInputBindings UIElement。)
ShouldSerializeProperty DependencyObject。)
ShouldSerializeResources FrameworkElement。)
ShouldSerializeStyle FrameworkElement。)
ShouldSerializeText Text 属性的有效值进行序列化。
ShouldSerializeTriggers FrameworkElement。)
ToString Object。)
TransformToAncestor(Visual) Visual。)
TransformToAncestor(Visual3D) Visual。)
TransformToDescendant Visual。)
TransformToVisual Visual。)
TranslatePoint UIElement。)
TryFindResource FrameworkElement。)
UnregisterName FrameworkElement。)
UpdateLayout UIElement。)
VerifyAccess DispatcherObject。)
             名称 说明
ContextMenuClosing FrameworkElement。)
ContextMenuOpening FrameworkElement。)
DataContextChanged FrameworkElement。)
DragEnter UIElement。)
DragLeave UIElement。)
DragOver UIElement。)
Drop UIElement。)
FocusableChanged UIElement。)
GiveFeedback UIElement。)
GotFocus UIElement。)
GotKeyboardFocus UIElement。)
GotMouseCapture UIElement。)
GotStylusCapture UIElement。)
GotTouchCapture UIElement。)
Initialized FrameworkElement。)
IsEnabledChanged UIElement。)
IsHitTestVisibleChanged UIElement。)
IsKeyboardFocusedChanged UIElement。)
IsKeyboardFocusWithinChanged UIElement。)
IsMouseCapturedChanged UIElement。)
IsMouseCaptureWithinChanged UIElement。)
IsMouseDirectlyOverChanged UIElement。)
IsStylusCapturedChanged UIElement。)
IsStylusCaptureWithinChanged UIElement。)
IsStylusDirectlyOverChanged UIElement。)
IsVisibleChanged UIElement。)
KeyDown UIElement。)
KeyUp UIElement。)
LayoutUpdated UIElement。)
Loaded FrameworkElement。)
LostFocus UIElement。)
LostKeyboardFocus UIElement。)
LostMouseCapture UIElement。)
LostStylusCapture UIElement。)
LostTouchCapture UIElement。)
ManipulationBoundaryFeedback UIElement。)
ManipulationCompleted UIElement。)
ManipulationDelta UIElement。)
ManipulationInertiaStarting UIElement。)
ManipulationStarted UIElement。)
ManipulationStarting UIElement。)
MouseDown UIElement。)
MouseEnter UIElement。)
MouseLeave UIElement。)
MouseLeftButtonDown UIElement。)
MouseLeftButtonUp UIElement。)
MouseMove UIElement。)
MouseRightButtonDown UIElement。)
MouseRightButtonUp UIElement。)
MouseUp UIElement。)
MouseWheel UIElement。)
PreviewDragEnter UIElement。)
PreviewDragLeave UIElement。)
PreviewDragOver UIElement。)
PreviewDrop UIElement。)
PreviewGiveFeedback UIElement。)
PreviewGotKeyboardFocus UIElement。)
PreviewKeyDown UIElement。)
PreviewKeyUp UIElement。)
PreviewLostKeyboardFocus UIElement。)
PreviewMouseDown UIElement。)
PreviewMouseLeftButtonDown UIElement。)
PreviewMouseLeftButtonUp UIElement。)
PreviewMouseMove UIElement。)
PreviewMouseRightButtonDown UIElement。)
PreviewMouseRightButtonUp UIElement。)
PreviewMouseUp UIElement。)
PreviewMouseWheel UIElement。)
PreviewQueryContinueDrag UIElement。)
PreviewStylusButtonDown UIElement。)
PreviewStylusButtonUp UIElement。)
PreviewStylusDown UIElement。)
PreviewStylusInAirMove UIElement。)
PreviewStylusInRange UIElement。)
PreviewStylusMove UIElement。)
PreviewStylusOutOfRange UIElement。)
PreviewStylusSystemGesture UIElement。)
PreviewStylusUp UIElement。)
PreviewTextInput UIElement。)
PreviewTouchDown UIElement。)
PreviewTouchMove UIElement。)
PreviewTouchUp UIElement。)
QueryContinueDrag UIElement。)
QueryCursor UIElement。)
RequestBringIntoView FrameworkElement。)
SizeChanged FrameworkElement。)
SourceUpdated FrameworkElement。)
StylusButtonDown UIElement。)
StylusButtonUp UIElement。)
StylusDown UIElement。)
StylusEnter UIElement。)
StylusInAirMove UIElement。)
StylusInRange UIElement。)
StylusLeave UIElement。)
StylusMove UIElement。)
StylusOutOfRange UIElement。)
StylusSystemGesture UIElement。)
StylusUp UIElement。)
TargetUpdated FrameworkElement。)
TextInput UIElement。)
ToolTipClosing FrameworkElement。)
ToolTipOpening FrameworkElement。)
TouchDown UIElement。)
TouchEnter UIElement。)
TouchLeave UIElement。)
TouchMove UIElement。)
TouchUp UIElement。)
Unloaded FrameworkElement。)
Windows phone 7之基础控件-属性与事件
属性描述的比较详细不过多讲解了,主要说一下有关布局的属性
Margin
Margin属性是表示外边距,也就是距离其他控件的距离,比如Margin=“10”便是距离四周是10像素,Margin=“10,5,4,3”或者Margin=“10 5 4 3”表示距离左边是10像素,上边是5像素,右边是4像素,下边是3像素
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBlock Margin="10 10 10 10" Text="Margin 10 10 10 10" />
<TextBlock Margin="30 30 30 30" Text="Margin 30 30 30 30" />
<TextBlock Margin="50 50 50 50" Text="Margin 50 50 50 50" />
<TextBlock Margin="100 100 100 100" Text="Margin 100 100 100 100"/>
</Grid>
上面代买设计中在预览窗口显示为

Windows phone 7之基础控件-属性与事件

可以看到Margin的四个边距都起到了作用,如果你设置了控件的Height和Width,那么默认只有左边距和上边距起作用,这事因为,一般的控件继承自FrameworkElement类,这个类有对齐属性,也就是VerticalAlignment(垂直对其方式)和HorizontalAlignment(水平对其方式),默认垂对齐方式是向上对齐,水平对齐方式是想做,而Margin的值是依据对齐方式起作用的,多以控件的Width和Height设为固定值时,空间的大小就不会随着Margin的值调整,也就无法做到,上下左右都满足。所以就出现了左和上起作用的现象。但是有一个前提,就是Margin的值不能太大,比如VerticalAlignment=“Top” ,但是如果你的Margin=“10 20 20 1000”就会出问题,Margin=“10 10 10 10”,下边距也是10,无法同时满足上下边距都是10,就会出现top优先,但是过大就会出现布局错误,即使设置了Height属性页没用,控件会被搞到屏幕外面去了,规律是,Margin.left+Margin.Right+控件Width小于父控件的Width+Padding或者Margin.Top+Margin.Bottom+控件Height小于父控件的Height+Padding,按照VerticalAlignment与HorizontalAlignment的设置来决定谁起作用,但是大于的话,就会吧控件挤到屏幕外面或者部分被掩盖

正正常情况下(Margin.left+Margin.Right+控件Width小于父控件的Width+Padding或者Margin.Top+Margin.Bottom+控件Height小于父控件的Height+Padding)对齐方式影响Margin的情况基本如下

VerticalAlignment=“Top” Margin.Top起作用

VerticalAlignment=“Botton”Margin.Bottom起作用

HorizontalAlignment=“Left” Margin.Left起作用

HorizontalAlignment=“Right”Margin.Right起作用

Padding属性和Margin类似,他表示内边距,也就是控件中,子空间与他的距离

如果Margin和Padding都设置了,那就把二者相加

Text属性用来设置显示的内容

其他属性不做介绍了,比如Foreground这种属性,再次出过多介绍没有任何意义,对于初学者来说,首先要掌握的就是空间的显示与布局

事件

Tap事件

Tap事件是当触摸控件时触发的事件,跟点击事件差不多,之所以又这种事件是因为Windows phone手机是触屏的,必须有触摸事件

看如下代码

xaml:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBlock Margin="10 10 10 10" Text="Margin 10 10 10 10" Tap="TextBlock_Tap" ManipulationStarted="TextBlock_ManipulationStarted" ManipulationDelta="TextBlock_ManipulationDelta" ManipulationCompleted="TextBlock_ManipulationCompleted"/>
<TextBlock Margin="30 30 30 30" Text="Margin 30 30 30 30" />
<TextBlock Margin="50 50 50 50" Text="Margin 50 50 50 50" />
<TextBlock Margin="100 100 100 100" Text="Margin 100 100 100 100"/>
</Grid>

c#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace Property
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}
string infoStr = "";
private void TextBlock_Tap(object sender, GestureEventArgs e)
{
infoStr += "Tap";
}

private void TextBlock_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
{
infoStr += "Start";
}

private void TextBlock_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
infoStr += "Delta";
}

private void TextBlock_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
{
string location = string.Format("X:{0},Y:{1}",e.ManipulationOrigin.X.ToString(),e.ManipulationOrigin.Y.ToString());
MessageBox.Show(location);
}
}
}

代码中e.ManipulationOrigin.X和e.ManipulationOrigin.Y分别是滑动后和滑动开始时两个点的距离,X表示X方向的巨鹿,Y表示Y方向的距离,他们的值根据您滑动的方向而定,可正可负,具体在以后的章节中介绍,运行程序,在第一个TextBlock控件上滑动一下,效果如下

Windows phone 7之基础控件-属性与事件

其他的一些时间和Win Form或者Web Form上类似了,一看事件名称就知道是什么意思,有关某些控件的特有属性和特有事件,在以后的章节中介绍

 

我新浪微博的昵称是“@马蔬菜”,多多关注,谢谢

相关文章: