Web Site/Web Application Item Template for Silverlight

來源:互聯網
上載者:User
 

Web Application Item Template and Web Site Item Template for Silverlight     First Kick    近日於使用Visual Studio 2005撰寫Silverlight範例時,發覺到每當寫一個範例,要不是複製Sence.xaml、Sence.xaml.cs,然後再修改裡面的程式碼,要不就是每次都得建立一個新的Silverlight專案才行,實在蠻不方便的,基於懶惰的本性,動了自訂Template的念頭。這次做了兩個Template,一個是用於Silverlight Project的,另一個是可用於Web Site(include ASP.NET Ajax Web Site),兩者用法大致相同。  ItemTemplate 的安裝  ItemTemplate的下載位址:http://www.dreams.idv.tw/~code6421/files/SLTemplate.zip 
Web Site 將SilverlightWebItemTemplate.zip放到My Documents/Visual Studio 2005/Templates/ItemTemplates/Visual Web Developer目錄下。
Web Application 將SilverlightItemTemplate.zip放到My Documents/Visual Studio 2005/Templates/ItemTemplates/Visual C#目錄下。
  Silverlight Item Template for Web Site   當正確將Template複制到ItemTemplate資料夾後,在建立Web Site或是Ajax Web Site之後,選取New Item便可看到下面的畫面。點選Add按紐後,這個ItemTemplate會建立四個檔案:.xaml、.xaml.cs、.ascx、.ascx.cs,如下圖。當然,你還得先將Silverlight.js複製到這個Web Site中。接著切換到要放入Silverlight的.aspx,加入引入Silverlight.js的程式碼。
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <title>Untitled Page</title></head><body>    <form id="form1" runat="server">        <asp:ScriptManager ID="ScriptManager1" runat="server" />        <script type="text/javascript" src="Silverlight.js"></script>        <div>        </div>    </form></body></html>
最後加入Page1這個UserControl到想要的位置即可。執行後結果如下。 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.