天天看點

Windows Phone 7 Tips (5)

1. Windows Phone 7 中的行為(行為、觸發器、動作統稱為行為)

基類 用法
Behavior < T > This is the simplest form of behavior in that it only exposes OnAttached and OnDetaching methods that you can override. You'd typically use these to wire up event handlers to the AssociatedObject (the XAML element that the behavior is attached to).
TriggerAction < T > One of the most common forms of behavior is the invocation of an action in response to an event. For example, you might want to navigate to a page when the user clicks a button. A TriggerAction allows the designer to specify which event on the associated control the behavior should observe. It then calls the overrideable Invoke method whenever the event triggers.
TargettedTriggerAction < T > The last form of behavior is an extension of the TriggerAction that allows the designer to specify the target element. Within the Invoke method you can reference the Target element, which may not be the same element that the behavior is attached to.

2. Windows Phone 7 中的Orientation的枚舉值

Windows Phone 7 Tips (5)

可以看到橫排、豎排等的值,你會很奇怪,怎麼數字這麼沒有規律,我們來看下這些數字對應的二進制值

Windows Phone 7 Tips (5)

你有沒有注意到Portrait相關的最低為都是1?

 3. Windows Phone 7 在設計頁面布局時需要考慮橫排、還是豎排。Orientation的一些政策為: Fixed Orientation、Auto-Layout、Manual Intervention、Changing States、Smoothing Transition

 4. 在Windows Phone 7 中,點選輸入框彈出來的鍵盤稱為SIP(Soft Input Panel),我們可以使用Pause Break在換電腦的鍵盤與SIP的切換

 5. ApplicationBar 暴露一個名為StateChanged事件,在該事件中你可以檢測ApplicationBar是否顯示,然後你可以在其中做一些界面布局的調整

 6. Windows Phone 7 中頁面布局有如下幾種方式

Windows Phone 7 Tips (5)

 7. 使用VSM跳轉到指定的狀态(State)

10. HttpWebRequest和WebClient的差別(From Linzheng):

1,HttpWebRequest是個抽象類,是以無法new的,需要調用HttpWebRequest.Create();

2,其Method指定了請求類型,這裡用的GET,還有POST;也可以指定ConentType;

3,其請求的Uri必須是絕對位址;

4,其請求是異步回調方式的,從BeginGetResponse開始,并通過AsyncCallback指定回調方法;

5,WebClient 方式使用基于事件的異步程式設計模型,在HTTP響應傳回時引發的WebClient回調是在UI線程中調用的,是以可用于更新UI元素的屬性,例如把 HTTP響應中的資料綁定到UI的指定控件上進行顯示。HttpWebRequest是基于背景程序運作的,回調不是UI線程,是以不能直接對UI進行操作,通常使用Dispatcher.BeginInvoke()跟界面進行通訊。