Silverlight for Windows Mobile非官方預覽

來源:互聯網
上載者:User
背景

Windows Embedded CE 6.0 R3已經包含了Silverlight for Embedded的功能,開發人員可以使用WPF的方式來開發Wince應用程式。關於Silverlight for Embedded,我之前寫了篇介紹性的文章,可以參考 User Interface Technologies for Windows Embedded CE。

 

什麼是Silverlight for Windows Mobile

嚴格來說說Silverlight是瀏覽器的外掛程式技術,不是應用程式開發技術。案頭技術叫做WPF,但是微軟又把用於Windows Embedded CE應用程式開發技術叫做Silverlight for Embedded。到底在Windows Mobile平台叫什麼,我也不知道,甚至到底什麼時候發布也沒有官方訊息。我姑且稱之為Silverlight for Windows Mobile,這是非官方命名,只做學習交流用。其實這個名稱可能不妥當,因為IE for Mobile在不久將來加入對Silverlight的支援,所以Silverlight for Windows Mobile有可能是專門針對Windows Mobile瀏覽器富應用的開發,but anyway,名字就那樣定,我的blog我做主。由於Windows Embedded CE 6.0 R3的Silverlight for Embedded只是支援Native C++的開發,有很多人猜測哪怕Windows Mobile 7 出來了,(備忘:Windows Mobile 7 是基於Windows Embedded CE 6的),.NET Compact Framework的開發還是沒辦法使用Silverlight。其實不是這樣的,進過 軒轅 TX的介紹,微軟最近發布的Bing for Windows phone是基於.NET Compact Framework,並且使用XAML技術來表現介面的程式。

 

實現預覽

下面偷窺一下Bing for Windows phone 的實現,姑且算是Silverlight for Windows Mobile的非官方預覽。Bing for Windows phone 把對XAML的分析和呈現都封裝到BingClient.exe裡面,我想未來的.NET Compact Framework會包含這些功能,現在微軟只是在實驗性的使用。先看一下安裝目錄。

安裝目錄下包含了XAML檔案夾,包含了所有介面布局和事件處理的定義。

realhome.xaml用於表達首頁面,首頁面如下:

其對應的XAML檔案realhome.xaml如下:

下面以菜單作為例子講述其實現,下面是菜單部分XAML的定義

<MenuItem Id="9800100" Name="MenuItemSpeak" Header="Speak" Click="Speech(SearchTabControl.xaml,Home)" />
<MenuItem Id="9800200" Name="MenuItemMain" Header="Menu">
<MenuItem Id="9800201" Name="MenuItemMaps" Header="Maps and Traffic" Click="HideAutoSuggest(AutoSuggestTextbox);LaunchMap(MapHomePPC.xaml,MapHomeSP.xaml,TheMap,NoPoi)" />
<MenuItem Id="9800202" Name="MenuItemBusinessDirectory" Header="Business Directory" Click="SetPropertyState(CurrentDomain,Local);SwitchPage(DomainLanding.xaml)" />
<MenuItem Id="9800203" Name="MenuItemTopNews" Header="Top News" Click="SetPropertyState(CurrentDomain,News);SwitchPage(DomainLanding.xaml)" />
<MenuItem Id="9800204" Name="MenuItemDirections" Header="Get Directions" Click="SwitchPage(MapLocationEntry.xaml)" />
<MenuItem Id="9800205" Name="MenuItemFavorites" Header="Recent and Favorites" Click="SwitchPage(RecentsFavorites.xaml);SwitchListTab(FavoriteRecentsTab,FavoritesTabHeader,Background,#a7b4bd,White,Foreground,White,#a7b4bd);SetFocus(FavoritesTabHeader)" />
<MenuItem Id="9800206" Name="MenuItemSeparator1" Header="-" />
<MenuItem Id="9800207" Name="MenuItemClientUpdate" Header="Update Available" Click="UpdateClient" Enabled="{Binding PropertyState.AllowClientUpdate}"/>
<MenuItem Id="9800208" Name="MenuItemSettings" Header="Settings" Click="SwitchPage(settings.xaml)" />
<MenuItem Id="9800209" Name="MenuItemHelp" Header="Help">
<MenuItem Id="9800219" Name="MenuItemHints" Header="Tips and Tricks" Click="SwitchPage(hintstips.xaml)" />
<MenuItem Id="9800229" Name="MenuItemFaq" Header="FAQ" Click="GoToUrl(http://appserver.m.bing.net/webdocs/en-us/brew/help.htm)" />
<MenuItem Id="9800239" Name="MenuItemAbout" Header="About" Click="SwitchPage(About.xaml)" />
<MenuItem Id="9800249" Name="MenuItemFeedback" Header="Feedback" Click="GoToUrl(https://feedback.discoverbing.com/default.aspx?productkey=bingmobile|P1=WinMo,mkt,Market,P2,ModelNumber,P3,BinaryVersion,P4,OSVersion,P5,Partner)" />
</MenuItem>
<MenuItem Name="MenuItemClose" Id="2613" Header="Exit" Click="Close" />
</MenuItem>

對應的菜單呈現如下:

菜單類MenuItemEx繼承了Winform的System.Windows.Forms.MenuItem。位於Microsoft.Search.Mobile.UI.Controls下,Microsoft.Search.Mobile.UI.Controls用於封裝所有解析XAML和呈現的控制項。

把各個控制項呈現到Winform裡面是通過一個form類View來實現。這樣XAML就可以通過傳統的Winform來呈現了。

public class View : Form

而這個View類由ViewManager類來控制到底如何呈現,呈現什麼,如何轉換呈現的內容。

public sealed class ViewManager : IViewManager

public interface IViewManager
{
void Dispose();
bool GoBack();
bool GoForward();
bool LoadView(string viewName, bool justParseXaml);
}

說到這裡,有興趣自己下載一個Bing for Windows phone 看一下。不管怎樣,我還是很高興知道微軟在做Silverlight for Windows Mobile的開發,在不久的將來,我們就可以使用XAML的模式來開發Windows Mobile應用程式來。本文內容只是用於學習研究,不能有任何其他用途。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.