教育訓練第一章
XAML介紹
屬性設定
設定方式:
1: 特性設定
2: 使用屬性元素
屬性繼承
XAML中的顔色和畫刷
Content屬性
資源定義和通路
共享機制 畫刷 外觀 文字等
Style使用與繼承
Style是屬性集合,也屬于資源,多用于對象元素
主題與漸變使用
Windows Phone預定了很多資源,通過StaticResource來用這些資源
資源包括:顔色,畫刷,字型名稱,字型大小,邊距等
教育訓練第二章 UI控件
基礎控件
控件繼承圖
布局控件
Grid
支援網格布局
自定義行列數
Grid.RowDefinitions 定義行
Grid.ColumnDefinitions 定義列
Auto表示此行根據内容自動調整
*代表取餘下的長度
Canvas
絕對布局的容器控件
使用Canvas.Left和Canvas.Top
Canvas.Zindex處理疊加處理
StackPanel
使多個子控件按照橫向或者縱向排列
Orientation(排列方向)
Horizontal
Vertical
三個Panel的差別
Border控件
繪制邊框
扮演容器控件角色
Image控件
顯示本地或者遠端圖檔
可以對圖檔進行裁剪,Mask
Shape控件
用于繪制幾何圖形
主要包括的控件
Ellipse(橢圓)
Polygon(多邊形)
Control控件
按鈕和選擇控件
按鈕:
Button
與使用者互動
Button可以做如下風格
内嵌圖檔
背景色
設定背景畫刷
設定背景為圖檔畫刷
HyperlinkButton
用來作為超連結按鈕
支援頁面導航
設定連結屬性:
NavigateUri="Http://";
NavigateUri="/MainPage.xaml";
RepeatButton
按下時,不斷的觸發Click事件
選擇控件:
CheckBox(選擇框控件)
為使用者提供選項,一般用于多選
支援三态:選中,中間态,未選中
注意:要使中間态有效需要設定如下: IsThreeState="true"
ReadioButton
使用者選擇控件,用于單選
分組方式有兩種
1:不同的分組,放到不同的容器
2:通過GruoupName屬性
Slider(滑杆控件)
以拖動方式在指定範圍内進行
屬性Orientation指定水準或者垂直
屬性Maximum和Minimum用于定義
文本控件
TextBlock
強大的文本标簽
lnlines(内聯屬性)
是LineBreak和Run對象的集合
一個内聯中,可以有多個LineBreak
LineBreak表示換行
Run可以對文本設定不同的字型顔色
TextBox
普通的文本采集控件
支援換行
TextWrapping="Wrap"
InputScope限定輸入内容
PasswordBox
密碼采集控件
屬性PasswordChan
Item控件
Pivot控件(樞軸控件)
虛拟出比手機寬度更寬的空間
水準方式組織多個螢幕内容
Pivot包含Pivotltem類型的子項
Pivotltem裡面可以是不同的控件
Panorama控件(全景控件)
虛拟出比手機寬度更寬的空間
水準方式組織多個螢幕内容
Panorama包含PanoramaItem類型
ScrollViewer
當子控件尺寸超出其大小時,可以進行拖動浏覽
滾動條屬性(預設隻能垂直滾動)
HorizontalScrollBarVisibility
VerticalScrollBarVisibility
PropressBar(進度條)
進度條控件
有兩種類型
進度遞增
幾個小點不斷循環
當知道具體的進度時,采用第一種,當進度不明确時,可采用第二種
ToolKit控件
ToolKit介紹與使用
微軟Siverlight團隊開發的一個産品,為了豐富windows phone的UI控件
導航效果(翻頁特效)
ListPicker
清單選擇控件
相當于Windows中的ComboBox控件
ListPickerItem:集合項
PhoneTextBox
進階的TextBox
支援:
Hint提示
Actionlcon(動作圖示)
字數限制提示
TiltEffect(控件傾斜)
替代使用者按下(pressed)和未按下(unpressed)
三個主要屬性
Tiltableltems
IsTiltEnabled
SupressTile
使用方法s
1: 全局傾斜
2: 應用到某個控件上
3: 靜止傾斜
4: 添加更多的控件到TiltableItems中
HubTile
輪詢磁貼
可以使用圖檔,标題,消息和通知
支援反轉
事件響應
事件
簡介
路由事件
事件的傳遞
從頂層控件傳遞到PhoneApplicationFrame
一些常見的事件:
PropertyChanged----屬性更改
Click---單擊
頁面導航相關事件
應用程式狀态變化通知事件
觸摸
原生觸摸
程式級别
提供比較低層的觸控程式設計接口
注冊Touch.FrameReported事件
事件資訊存放在TouchFrameEvent
參數屬性:
Timestamp:擷取事件
進階觸摸
Manipulation
手勢識别
<Grid x:Name="LayoutRoot" Background="Transparent">
<!--
<Grid Margin="10,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="130" />
<RowDefinition Height="130" />
<RowDefinition Height="*" />
<RowDefinition Height="130" />
<RowDefinition Height="130" />
</Grid.RowDefinitions>
<Grid x:Name="RowOne" Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120" />
<ColumnDefinition Width="120" />
<ColumnDefinition Width="120" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Grid.Column="0"
Content="月曆"
Style="{StaticResource gb}" />
<Button Grid.Column="1"
Content="系統"
Style="{StaticResource gb}" />
<Button Grid.Column="2"
Content="網絡"
Style="{StaticResource gb}" />
<Button Grid.Column="3"
Content="短信"
Style="{StaticResource gb}" />
</Grid>
<Grid Grid.Row="1">
<Button Width="120"
HorizontalAlignment="Left"
Content="視訊"
Style="{StaticResource gb}" />
<Button Width="120"
HorizontalAlignment="Right"
Content="錄音"
Style="{StaticResource gb}" />
</Grid>
<Grid Grid.Row="2">
<Button Width="400"
Content="商店"
FontSize="60"
Style="{StaticResource gb}" />
</Grid>
<Grid Grid.Row="3">
<Button HorizontalAlignment="Left"
Content="幫助"
Style="{StaticResource gb}" />
<Button HorizontalAlignment="Right"
Content="設定"
Style="{StaticResource gb}" />
</Grid>
<Grid Grid.Row="4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120" />
<ColumnDefinition Width="120" />
<ColumnDefinition Width="120" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Grid.Column="0"
Content="閱讀"
Style="{StaticResource gb}" />
<Button Grid.Column="1"
Content="UC"
Style="{StaticResource gb}" />
<Button Grid.Column="2"
Content="QQ"
Style="{StaticResource gb}" />
<Button Grid.Column="3"
Content="更新"
Style="{StaticResource gb}" />
</Grid>
</Grid>
-->
<!--
<Canvas Width="100"
Height="100"
Background="Brown"
Left="150"
Top="150"
ZIndex="3" />
<Canvas Width="200"
Height="200"
Background="Blue"
Left="100"
Top="100"
ZIndex="2" />
<Canvas Width="300"
Height="300"
Background="Chartreuse"
Left="50"
Top="50"
ZIndex="1" />
-->
<!-- 靠沒達到理想的效果 -->
<!--
<StackPanel Orientation="Vertical">
<Button Height="150" Content="确定" />
<Grid Height="300" Background="Brown">
<StackPanel Orientation="Horizontal">
<Button Height="100" Content="登入" />
<Button Height="100" Content="退出" />
</StackPanel>
</Grid>
</StackPanel>
-->
<!--
<Border Width="400"
Height="200"
Margin="28,150,28,275"
Background="Red"
BorderBrush="Green"
BorderThickness="50,0,50,0"
CornerRadius="100">
<Button Content="Button" />
</Border>
-->
<!--
<Image Width="339"
Height="244"
HorizontalAlignment="Center"
Source="./Windows-Phone-8.jpg" />
-->
<!--
<Grid x:Name="ContentPanel"
Grid.Row="1"
Margin="12,0,12,0">
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<Ellipse Width="200"
Height="200"
Fill="Green" />
<Rectangle Width="200"
Height="50"
Fill="Red" />
</StackPanel>
</Grid>
-->
<!-- button -->
<!--
<Button Name="button1"
Width="321"
Height="89"
Margin="87,-5,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top">
<Button.Content>
<Image Width="218" Source="Windows-Phone-8.jpg" />
</Button.Content>
</Button>
<Button Name="button2"
Width="321"
Height="72"
Margin="87,82,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="#FFB81BD4"
BorderBrush="CadetBlue"
Content="Button" />
<Button Name="button3"
Width="321"
Height="72"
Margin="87,153,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Content="Button">
<Button.Background>
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
<GradientStop Offset="0" Color="BlueViolet" />
<GradientStop Offset="1" Color="CadetBlue" />
</LinearGradientBrush>
</Button.Background>
</Button>
<Button Name="button4"
Height="72"
Margin="87,225,48,0"
VerticalAlignment="Top"
Content="Button">
<Button.Background>
<ImageBrush ImageSource="Windows-Phone-8.jpg" />
</Button.Background>
</Button>
<HyperlinkButton Name="htperlinkButton1"
Width="321"
Height="66"
Margin="87,391,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="Brown"
Content="www.baidu.com"
NavigateUri="Http://www.baidu.com"
TargetName="devdiv" />
<HyperlinkButton Name="hyperlinkButton2"
Width="321"
Height="59"
Margin="87,309,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="Chartreuse"
Content="MainPage"
NavigateUri="MainPage.xaml" />
<RepeatButton Name="repeatButton"
Width="321"
Height="81"
Margin="87,462,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="DarkBlue"
Click="repeaBtn_Click"
Content="0"
Delay="400" />
-->
<!-- CheckBox -->
<!--
<CheckBox Name="mychkBox"
Width="190"
VerticalAlignment="Top"
Background="Brown"
Checked="chkBox_Checked"
Foreground="Chartreuse"
IsThreeState="True"
Unchecked="chkBox_Unchecked">
<CheckBox.RenderTransform>
<CompositeTransform ScaleX="1.5" ScaleY="1.5" />
</CheckBox.RenderTransform>
</CheckBox>
<RadioButton Name="radioButton1"
Width="220"
Height="72"
Margin="145,225,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="Blue"
Content="男" />
<RadioButton Name="radioButton2"
Width="220"
Height="72"
Margin="245,225,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="Blue"
Content="女" />
-->
<!-- Slider -->
<!--
<TextBlock Name="sliderText" />
<Slider Name="slider"
Width="407"
Height="115"
Margin="49,482,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
LargeChange="2"
Maximum="100"
Minimum="0"
SmallChange="0.1"
ValueChanged="slider_ValueChanged" />
<Slider Name="slider2"
Width="59"
Height="325"
Margin="6,0,0,55"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Background="Brown"
BorderBrush="Chartreuse"
Foreground="Black"
Orientation="Vertical"
ValueChanged="slider_ValueChanged" />
-->
<!-- TextBlock -->
<!--
<StackPanel Width="456"
Height="607"
HorizontalAlignment="Left"
VerticalAlignment="Top">
<TextBlock Width="253"
Height="114"
Margin="87,0,0,0"
HorizontalAlignment="Left"
TextWrapping="Wrap">
<TextBlock.Inlines>
<Run FontSize="30"
FontStyle="Italic"
FontWeight="Thin"
Foreground="#ff1fdb3c"
Text="Windows Phone 8" />
<LineBreak />
<Run FontSize="30"
Foreground="Blue"
Text="開發" />
<Run FontSize="50"
Foreground="Chartreuse"
Text="體驗" />
</TextBlock.Inlines>
</TextBlock>
<TextBox Width="410"
Height="221"
Margin="87,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
InputScope="Text"
Text="TextBox"
TextWrapping="Wrap" />
<PasswordBox Width="410"
Height="93"
Margin="36,0,0,0"
HorizontalAlignment="Left"
PasswordChar="*" />
</StackPanel>
-->
<!-- pivot -->
<!--
<phone:Pivot Title="Pivot控件">
<phone:Pivot.Background>
<ImageBrush ImageSource="Windows-Phone-8.jpg" />
</phone:Pivot.Background>
<phone:PivotItem Header="文本">
<TextBox Width="436"
Height="589"
Margin="10,10,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="BlueViolet"
Foreground="CadetBlue"
Text=" W Indows Phone 8是微軟公司6月21日最新釋出的一款手機作業系統,是Windows Phone系統的最新版本,也是目前Windows Phone的第三個大型版本。Windows Phone 8采用和Windows 8相同的針對移動平台精簡優化NT核心并内置諾基亞地圖。"
TextWrapping="Wrap" />
</phone:PivotItem>
<phone:PivotItem Header="圖檔">
<ScrollViewer Name="scrollViewer1"
Width="446"
Height="597"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="Chartreuse"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<Image Name="img"
Width="800"
Height="600"
Source="Windows-Phone-8.jpg" />
</ScrollViewer>
</phone:PivotItem>
</phone:Pivot>
-->
<!--
<phone:Panorama Title="Panorama控件">
<phone:Panorama.Background>
<ImageBrush ImageSource="Windows-Phone-8.jpg" />
</phone:Panorama.Background>
<phone:PanoramaItem Header="文本">
<TextBox Width="436"
Height="468"
Margin="0,0,0,15"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Background="Brown"
Foreground="CadetBlue"
Text="WIndows Phone 8是微軟公司6月21日最新釋出的一款手機作業系統,是Windows Phone系統的最新版本,也是目前Windows Phone的第三個大型版本。Windows Phone 8采用和Windows 8相同的針對移動平台精簡優化NT核心并内置諾基亞地圖。"
TextWrapping="Wrap" />
</phone:PanoramaItem>
<phone:PanoramaItem Header="圖檔">
<ScrollViewer Name="scrollViewer1"
Width="446"
Height="600"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="Chocolate"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<Image Name="img"
Width="800"
Height="600"
Source="Windows-Phone-8.jpg"
Stretch="Fill" />
</ScrollViewer>
</phone:PanoramaItem>
</phone:Panorama>
-->
<!--
<ScrollViewer Name="scrollViewer1"
Width="362"
Height="362"
Margin="41,67,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="DarkKhaki"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<Image Name="img"
Width="500"
Height="400"
Source="Windows-Phone-8.jpg"
Stretch="Fill" />
</ScrollViewer>
-->
<!-- 進度條 ProgressBar -->
<!--
<ProgressBar Name="progressBar2"
Width="431"
Height="34"
Margin="25,317,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
IsIndeterminate="True" />
<ProgressBar Name="progressbar1"
Width="431"
Height="20"
Margin="25,204,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Value="50" />
-->
<!-- ToolKit -->
<!--
<Grid x:Name="ContentPanel"
Grid.Row="1"
Margin="12,0,12,0">
<toolKit:PhoneTextBox Margin="-10,96,10,435"
ActionIcon="Windows-Phone-8.jpg"
ActionIconTapped="Search_ActionIconTapped"
Hint="請輸入搜尋内容"
HintStyle="{StaticResource HintCustomStyle}"
LengthIndicatorVisible="True"
MaxLength="10" />
<toolKit:ListPicker>
<toolKit:ListPickerItem Content="睡覺" />
<toolKit:ListPickerItem Content="上班" />
<toolKit:ListPickerItem Content="下班" />
</toolKit:ListPicker>
<Button Name="button"
Width="251"
Margin="80,206,0,342"
HorizontalAlignment="Left"
Background="Red"
Content="斜"
Foreground="White" />
</Grid>
-->
<!--
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<toolKit:HubTile Title="藝術"
Grid.Row="0"
Grid.Column="0"
Width="218"
Height="172"
Margin="5,10,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="BurlyWood"
DisplayNotification="true"
Message="多彩貴州 舞蹈大賽決賽在貴州電視台演播廳舉行。圖為女子集體民族民間舞比賽中。黔中早報 羅禹 攝"
Notification="5"
Source="/images/00.jpg"
Tap="hubTile_Tap" />
<toolKit:HubTile Title="奧運"
Grid.Row="0"
Grid.Column="1"
Width="218"
Height="172"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="BurlyWood"
DisplayNotification="True"
Message="英國倫敦,2012奧運會閉幕式現場。"
Notification="6"
Source="/images/01.jpg"
Tap="hubTile_Tap" />
<toolKit:HubTile Title="風情"
Grid.Row="1"
Grid.Column="0"
Width="218"
Height="172"
Margin="5,10,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="CadetBlue"
DisplayNotification="True"
Message="印度孟買,印度教信徒們在疊羅漢,組成人體金字塔。疊羅漢是印度教徒的傳統活動,以慶祝神明克利須那神"
Notification="8"
Source="/images/10.jpg"
Tap="hubTile_Tap" />
<toolKit:HubTile Title="少兒"
Grid.Row="1"
Grid.Column="1"
Width="218"
Height="172"
Margin="5,10,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="Chocolate"
DisplayNotification="true"
Message="在安徽省亳州市文帝東路亳州體操訓練基地體操館内,孩子們正在教練的指導下強化訓練。"
Notification="10"
Source="/images/11.jpg"
Tap="hubTile_Tap" />
<toolKit:HubTile Title="國際"
Grid.Row="2"
Grid.Column="0"
Width="218"
Height="172"
Margin="5,10,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="Coral"
DisplayNotification="true"
Message="一名男子正在參拜位于東京的靖國神社。當天是日本二戰投降67周年。"
Notification="1"
Source="/images/20.jpg"
Tap="hubTile_Tap" />
<toolKit:HubTile Title="新聞"
Grid.Row="2"
Grid.Column="1"
Width="218"
Height="172"
Margin="5,10,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="BurlyWood"
DisplayNotification="true"
Message="載有14人的香港保釣船啟豐二号成功登上釣魚島,并将五星紅旗插在釣魚島上。"
Notification="9"
Source="/images/21.jpg"
Tap="hubTile_Tap" />
<toolKit:HubTile Title="環保"
Grid.Row="3"
Grid.Column="0"
Width="218"
Height="172"
Margin="5,10,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="Coral"
DisplayNotification="True"
Message="陳光标和《甄嬛傳》中槿汐的扮演者孫茜将現場的鉛酸電池電動車砸碎,斷然拒絕鉛污染。"
Notification="4"
Source="/images/30.jpg"
Tap="hubTile_Tap" />
<toolKit:HubTile Title="電影"
Grid.Row="3"
Grid.Column="1"
Width="218"
Height="172"
Margin="5,10,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="Chartreuse"
DisplayNotification="True"
Message="第69屆威尼斯電影節開幕。意大利女星瑪裡尼-瓦勒麗亞走紅毯。"
Notification="7"
Source="/images/31.jpg"
Tap="hubTile_Tap" />
-->
<!--
<Grid x:Name="ContentPanel"
Grid.Row="1"
Margin="12,0,12,0">
<StackPanel>
<TextBlock Name="textBlick1" TextWrapping="Wrap" />
<TextBlock Name="textBlick2" TextWrapping="Wrap" />
<TextBlock Name="textBlick3" TextWrapping="Wrap" />
<TextBlock Name="textBlick4" TextWrapping="Wrap" />
<TextBlock Name="textBlick5" TextWrapping="Wrap" />
<TextBlock Name="textBlick6" TextWrapping="Wrap" />
</StackPanel>
<Button Height="100"
VerticalAlignment="Center"
Background="Blue"
Content="點選" />
</Grid>
-->
<Grid x:Name="ContentPanel"
Grid.Row="1"
Margin="12,0,12,0">
<TextBlock Name="txtBlk"
VerticalAlignment="Top"
Text="" />
<Button Name="btn"
Width="169"
Height="132"
Margin="133,136,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Content="拖我啊!"
ManipulationCompleted="btn_ManipulationCompleted"
ManipulationDelta="btn_ManipulationDelta"
ManipulationStarted="btn_ManipulationStarted">
<Button.RenderTransform>
<TranslateTransform x:Name="translatedTransform" />
</Button.RenderTransform>
</Button>
</Grid>
</Grid>
//private void repeaBtn_Click(object sender, RoutedEventArgs e)
//{
//int count = Convert.ToInt32(repeatButton.Content);
//repeatButton.Content = ++count;
//}
/*private void chkBox_Checked(object sender, RoutedEventArgs e)
{
if (mychkBox.IsChecked == true)
{
MessageBox.Show("選擇");
}
}
private void chkBox_Unchecked(object sender, RoutedEventArgs e)
{
if (mychkBox.IsChecked == false)
{
MessageBox.Show("未選");
}
}*/
/*private void slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
Slider slidertemp = (Slider) sender;
this.sliderText.Text = slidertemp.Value.ToString();
}*/
/*private void Search_ActionIconTapped(object sendeer, EventArgs e)
{
MessageBox.Show("開始搜尋!");
}*/
/*private void hubTile_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
HubTile tile = (HubTile) sender;
MessageBox.Show(tile.Message, tile.Title, MessageBoxButton.OK);
}*/
/*private void TouchFrameReported(object sender, TouchFrameEventArgs e)
{
//傳入null表明擷取到的觸控點資訊是以螢幕左上角為原點的
TouchPoint mainPoint = e.GetPrimaryTouchPoint(null);
if (mainPoint != null)
{
textBlick1.Text = "主觸控點的行為,Action: "+mainPoint.Action.ToString();
textBlick2.Text = "主觸控點位置,Position: X" + mainPoint.Position.X.ToString()+"Y:"+mainPoint.Position.Y.ToString();
textBlick3.Text = "主觸控點的範圍,Size.Width:"+mainPoint.Size.Width.ToString()+",Size.Height:"+mainPoint.Size.Height.ToString();
textBlick4.Text = "主觸控點設定ID,TouchDevice.Id:"+mainPoint.TouchDevice.Id.ToString();
textBlick5.Text = "主觸控點點中哪 個UIElement元素:" + (mainPoint.TouchDevice.DirectlyOver as FrameworkElement).Name.ToString();
}
TouchPointCollection points = e.GetTouchPoints(null);
int i = 0;
textBlick6.Text = "";
if (points != null)
{
//列舉觸控點的集合
foreach (var point in points)
{
i++;
textBlick6.Text += "Position" + i + "X:" + point.Position.X.ToString() + " Y" + i + " " +
point.Position.Y.ToString() + " " + point.Action.ToString() + "\n";
}
}
}*/
private void btn_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
{
txtBlk.Text = "btn_ManipulationStarted";
}
private void btn_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
//使控件跟着觸控點走
this.translatedTransform.X += e.DeltaManipulation.Translation.X;
this.translatedTransform.Y += e.DeltaManipulation.Translation.Y;
txtBlk.Text = "btn_ManipulationDelta"+"\n"+" Translation X:"+e.DeltaManipulation.Translation.X+" Y:"+e.DeltaManipulation.Translation.Y+"\n"
+"Cumulative X:"+e.CumulativeManipulation.Translation.X+" Y:"+e.CumulativeManipulation.Translation.Y+" LinearVelocity X:"+e.Velocities.LinearVelocity.X+" Y:"+e.Velocities.LinearVelocity.Y+" IsInertial:"+e.IsInertial;
}
private void btn_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
{
txtBlk.Text = "btn_ManipulationCompleted "+"\n"+" TotalManipulation.Translation.X:"+e.TotalManipulation.Translation.X+" Y:"+e.TotalManipulation.Translation.Y+"\n"+"FinalVelocities: X:"+e.FinalVelocities.LinearVelocity.X+" Y:"+e.FinalVelocities.LinearVelocity.Y+" IsInertial:"+e.IsInertial;
}