自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Silverlight引用資源具體方法介紹

開發(fā) 開發(fā)工具
Silverlight引用資源的方法總共可以分為三種,分別為:資源 Resource、內(nèi)容 content 和 none。本文將會為大家詳細介紹其中概念。

Silverlight開發(fā)工具的應用方法是比較簡單的。在實際的開發(fā)程序中,可以幫助開發(fā)人員輕松的實現(xiàn)各種視頻音頻WEB應用程序。在這里我們將會了解到有關Silverlight引用資源的一些相關介紹。#t#

下面討論三種在工程中Silverlight引用資源的方法:資源 Resource、內(nèi)容 content 和 none。

Silverlight引用資源1、默認情況下 mainPage.xaml 的 Build action 是 Page,而加入的資源文件則是 Resource。這樣,我們加入到 應用的根目錄下的圖片可以這樣引用。

  1. < UserControl x:Class="_009_uri.MainPage" 
  2. xmlns="http://schemas.microsoft.
    com/winfx/2006/xaml/presentation"
       
  3. xmlns:x="http://schemas.microsoft.
    com/winfx/2006/xaml"
     
  4. xmlns:d="http://schemas.microsoft.
    com/expression/blend/2008"
     xmlns:mc=
    "http://schemas.openxmlformats.org
    /markup-compatibility/2006"
       
  5. mc:Ignorable="d" d:DesignWidth="640" 
    d:DesignHeight="480"> 
  6. < Grid x:Name="LayoutRoot"> 
  7. < Image Source="./blend.jpg">< /Image> 
  8. < /Grid> 
  9. < /UserControl> 

 

編譯后,可以看到圖片。

資源(Resource):這個build action選項會將文件嵌入項目的程序集中。這個選項意味著,如果你添加了一個視頻,那么你生成的xap會比你想象中的要大一些。

Silverlight引用資源2、 按照內(nèi)容的方式進行 build。我們先看一下代碼:

  1.  
  2. < UserControl x:Class="_009_uri.MainPage" 
  3. xmlns="http://schemas.microsoft.com
    /winfx/2006/xaml/presentation"
       
  4. xmlns:x="http://schemas.microsoft.
    com/winfx/2006/xaml"
     
  5. xmlns:d="http://schemas.microsoft.com
    /expression/blend/2008"
     xmlns:mc=
    "http://schemas.openxmlformats.org
    /markup-compatibility/2006"
       
  6. mc:Ignorable="d" d:DesignWidth="640"
     d:DesignHeight="480"> 
  7. < Grid x:Name="LayoutRoot"> 
  8. < Image Source="./blend.jpg" Width="250"
     Margin="0,0,300,0">< /Image> 
  9. < MediaElement Source="./old6.mp4"
     Margin="250,50,0,0" Width="200">
  10. < /MediaElement> 
  11. < /Grid> 
  12. < /UserControl> 

 

雖然引用的方式?jīng)]有變化,但是此時我們必須將 jpg 和 mp4 文件放到網(wǎng)站的 ClientBin 或者其他和我們的應用同級的目錄中,才能夠正常的訪問,而此時,我們生成的 xap 又變成了一個小巧的文件包。

如果我們不適用相對的路徑,仍然可以用絕對的路徑來訪問我們的應用。

 

  1. < UserControl x:Class="_009_uri.MainPage" 
  2. xmlns="http://schemas.microsoft.com/
    winfx/2006/xaml/presentation"
       
  3. xmlns:x="http://schemas.microsoft.com
    /winfx/2006/xaml"
     
  4. xmlns:d="http://schemas.microsoft.com
    /expression/blend/2008"
     xmlns:mc="http
    ://schemas.openxmlformats.org/markup-
    compatibility/2006"
       
  5. mc:Ignorable="d" d:DesignWidth="640" 
    d:DesignHeight="480"> 
  6. < Grid x:Name="LayoutRoot"> 
  7. < Image Source="./blend.jpg" Width="250"
     Margin="0,0,300,0">< /Image> 
  8. < MediaElement Source="http://localhost
    :7323/009_uri.Web/ClientBin/old6.mp4"
     
    Margin="250,50,0,0" Width="200">
  9. < /MediaElement> 
  10. < /Grid> 
  11. < /UserControl> 

 

我認為,這種方法使我們?nèi)粘m椖恐薪?jīng)常用到的。

 

另外,如果我們使用前導斜杠(/)的相對URI,則表示我們要基于應用程序跟的位置來尋找Silverlight引用資源。

 

  1. < UserControl x:Class="_009_uri.MainPage" 
  2. xmlns="http://schemas.microsoft.com
    /winfx/2006/xaml/presentation"
       
  3. xmlns:x="http://schemas.microsoft
    .com/winfx/2006/xaml"
     
  4. xmlns:d="http://schemas.microsoft.
    com/expression/blend/2008"
     xmlns:mc=
    "http://schemas.openxmlformats.org
    /markup-compatibility/2006"
       
  5. mc:Ignorable="d" d:DesignWidth="640" 
    d:DesignHeight="480"> 
  6. < Grid x:Name="LayoutRoot"> 
  7. < Image Source="./blend.jpg" 
    Width="250" Margin="0,0,300,0">< /Image> 
  8. < MediaElement Source="/../Assets/
    old6.mp4"
     Margin="250,50,0,0" 
    Width="200">< /MediaElement> 
  9. < /Grid> 
  10. < /UserControl> 

Silverlight引用資源3、build action 為 none的時候,我們可以按照2的方式來進行引用。

責任編輯:曹凱 來源: 博客園
相關推薦

2009-12-31 15:05:00

Silverlight

2009-12-16 15:04:26

Ruby實現(xiàn)strea

2009-11-23 15:10:28

PHP獲取當前url

2010-03-19 15:47:49

Python語法檢查

2009-12-01 13:41:49

靜態(tài)路由設置

2009-12-01 09:52:40

PHP過濾字符串

2009-11-30 11:24:49

PHP將EXCEL導入

2009-11-24 17:25:00

PHP二維數(shù)組排序

2010-07-21 14:33:01

刪除telnet

2009-12-29 18:02:26

SilverLight

2009-12-03 14:43:46

phpMyAdmin配

2011-04-01 13:34:12

zabbix

2010-01-04 15:21:37

Silverlight

2009-12-29 18:34:21

Silverlight

2009-12-15 13:47:33

Silverlight

2009-12-31 17:21:41

Silverlight

2010-04-23 13:53:29

Oracle密碼

2009-12-25 16:52:57

網(wǎng)絡接入控制

2010-02-06 11:19:33

C++獲取文件

2009-11-23 19:16:32

路由器測試
點贊
收藏

51CTO技術棧公眾號