日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

Windows Presentation Foundation(WPF)中的數(shù)據(jù)綁定(使用XmlDataProvider作控件綁定之二:使用外部URL的XML文件)

 louisasea 2007-11-21
 Windows Presentation Foundation(WPF)中的數(shù)據(jù)綁定(使用XmlDataProvider作控件綁定之二:使用外部URL的XML文件)     CSDN blog推出文章指數(shù)概念,文章指數(shù)是對blog文章綜合評分后推算出的,綜合評分項(xiàng)分別是該文章的點(diǎn)擊量,回復(fù)次數(shù),被網(wǎng)摘收錄數(shù)量,文章長度和文章類型;滿分100,每月更新一次。

--------------------------------------------------------------------------------
引用或轉(zhuǎn)載時(shí)請保留以下信息:
大可山 [MSN:a3news(AT)hotmail.com]
http://www. http://www.
蘿卜鼠在線圖形圖像處理
--------------------------------------------------------------------------------

3、使用外部URL鏈接的XML文件作為數(shù)據(jù)源
事實(shí)上,在上文Windows Presentation Foundation(WPF)中的數(shù)據(jù)綁定(使用XmlDataProvider作控件綁定) 中,XmlDataProvider的Source屬性還可以直接指向你本機(jī)的某個(gè)XML文件:
<XmlDataProvider x:Key="FavoriteColors" Source="E:\Books\xaml\FavoriteColors.xml" />

我們還可以指向任何標(biāo)準(zhǔn) URL,這樣,我們就可以創(chuàng)建對XML API(如 RSS)的快速訪問。
比如,我的BLOG中關(guān)于WPF的RSS地址是:http://blog.csdn.net/johnsuna/category/325343.aspx/rss,下面我使用TextBlock來顯示BLOG的標(biāo)題,用ListBox來顯示所有文章的題目。

<Window
 xmlns=" >
<Canvas x:Name="LayoutRoot">
<StackPanel Height="243.687">
  <StackPanel.Resources>
   <XmlDataProvider x:Key="MyRSS"
    Source="
http://blog.csdn.net/johnsuna/category/325343.aspx/rss" />
 </StackPanel.Resources>

 <TextBlock x:Name="txtBlockTitle" Text="{Binding Source={StaticResource MyRSS}, XPath=//channel/title}" HorizontalAlignment="Center"
               FontWeight="Bold"/>
 <ListBox Width="500" Height="300"
             ItemsSource="{Binding Source={StaticResource MyRSS}, XPath=//item/title}">
 </ListBox>
 </StackPanel>
</Canvas>
</Window> 

上面 XPath=//channel/title , XPath=//item/title分別對應(yīng)下面的具體內(nèi)容,你可以結(jié)合起來仔細(xì)分析一下。(如果你對XPath的相關(guān)細(xì)節(jié)不夠了解,建議你看一下XSLT相關(guān)的書或者到以下鏈接:http://www./TR/xpath,http://www./xpath/default.asp

這是http://blog.csdn.net/johnsuna/category/325343.aspx/rss的部分內(nèi)容:(注意我特別加粗的部分)
<rss version="2.0" xmlns:dc="http:///dc/elements/1.1/" xmlns:trackback="http:///public/xml/rss/module/trackback/" xmlns:wfw="http:///CommentAPI/" xmlns:slash="http:///rss/1.0/modules/slash/">
<channel>
  <title>Johnson(大可山)的專欄 -</title>

  <link>http://blog.csdn.net/johnsuna/category/325343.aspx</link>
  <description />
  <dc:language>af</dc:language>
  <generator>.Text Version 1.0.1.1</generator>
  <image>http://counter.csdn.net/pv.aspx?id=72</image>
 <item>
  <dc:creator>大可山</dc:creator>
  <title>Windows Presentation Foundation(WPF)中的數(shù)據(jù)綁定(使用XmlDataProvider作控件綁定)</title>
  <link>http://blog.csdn.net/johnsuna/archive/2007/08/21/1753001.aspx</link>
  <pubDate>Tue, 21 Aug 2007 15:59:00 GMT</pubDate>
  <guid>http://blog.csdn.net/johnsuna/archive/2007/08/21/1753001.aspx</guid>
  <wfw:comment>http://blog.csdn.net/johnsuna/comments/1753001.aspx</wfw:comment>
  <comments>http://blog.csdn.net/johnsuna/archive/2007/08/21/1753001.aspx#Feedback</comments>
  <slash:comments>0</slash:comments>
  <wfw:commentRss>http://blog.csdn.net/johnsuna/comments/commentRss/1753001.aspx</wfw:commentRss>
  <trackback:ping>http://tb.blog.csdn.net/TrackBack.aspx?PostId=1753001</trackback:ping>
  <description><img src =" </item>
 <item>
  <dc:creator>大可山</dc:creator>
  <title>Windows Presentation Foundation(WPF)中的數(shù)據(jù)綁定(控件與控件值的綁定)</title>
  <link>http://blog.csdn.net/johnsuna/archive/2007/08/21/1752865.aspx</link>
  <pubDate>Tue, 21 Aug 2007 14:51:00 GMT</pubDate>
  <guid>http://blog.csdn.net/johnsuna/archive/2007/08/21/1752865.aspx</guid>
  <wfw:comment>http://blog.csdn.net/johnsuna/comments/1752865.aspx</wfw:comment>
  <comments>http://blog.csdn.net/johnsuna/archive/2007/08/21/1752865.aspx#Feedback</comments>
  <slash:comments>0</slash:comments>
  <wfw:commentRss>http://blog.csdn.net/johnsuna/comments/commentRss/1752865.aspx</wfw:commentRss>
  <trackback:ping>http://tb.blog.csdn.net/TrackBack.aspx?PostId=1752865</trackback:ping>
  <description>使用類似{Binding ElementName=txtBoxInput,Path=Text}的方式進(jìn)行控件與控件的綁定<img src ="
 </item>
<!-- 還有更多 -->
</channel>
</rss>

下圖是顯示效果:
使用RSS等外部文件進(jìn)行WPF控件綁定

    本站是提供個(gè)人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多