博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
数据绑定:从DHTML迁移到Xmal(1)
阅读量:6478 次
发布时间:2019-06-23

本文共 3017 字,大约阅读时间需要 10 分钟。

从最简单的开始:

在DHTML中,我们可以使用数据岛进行数据绑定,参考
例子:
--------------------test.htm-------------------------

None.gif
<
xml 
id
='DataSource'
>
None.gif      
<
Books
>
None.gif        
<
Book 
ISBN
="0-7356-0562-9"
 Stock
="in"
>
None.gif          
<
Title
>
XML in Action
</
Title
>
None.gif          
<
Summary
>
XML Web Technology
</
Summary
>
None.gif        
</
Book
>
None.gif        
<
Book 
ISBN
="0-7356-1370-2"
 Stock
="in"
>
None.gif          
<
Title
>
Programming Microsoft Windows With C#
</
Title
>
None.gif          
<
Summary
>
C# Programming using the .NET Framework
</
Summary
>
None.gif        
</
Book
>
None.gif        
<
Book 
ISBN
="0-7356-1288-9"
 Stock
="out"
>
None.gif          
<
Title
>
Inside C#
</
Title
>
None.gif          
<
Summary
>
C# Language Programming
</
Summary
>
None.gif        
</
Book
>
None.gif        
<
Book 
ISBN
="0-7356-1377-X"
 Stock
="in"
>
None.gif          
<
Title
>
Introducing Microsoft .NET
</
Title
>
None.gif          
<
Summary
>
Overview of .NET Technology
</
Summary
>
None.gif        
</
Book
>
None.gif        
<
Book 
ISBN
="0-7356-1448-2"
 Stock
="out"
>
None.gif          
<
Title
>
Microsoft C# Language Specifications
</
Title
>
None.gif          
<
Summary
>
The C# language definition
</
Summary
>
None.gif        
</
Book
>
None.gif      
</
Books
>
None.gif
</
xml
>
None.gif
<
H3
>
XML Data Source Sample
</
H3
>
None.gif
<
table 
datasrc
="#DataSource"
>
None.gif
<
tr
>
None.gif
<
td
>
None.gif
<
span 
datafld
="Title"
></
span
>
None.gif
</
td
>
None.gif
</
tr
>
None.gif
</
table
>
--------------------------------------------------------------
迁移到XMAL中,参考
ms-help://MS.MSDNQTR.v80.en/MS.MSDN.v80/MS.WinFX4VS.1033/Wcp_samples/local/samplehtmlsources/ConnectedData/XmlDataSource/XAML/Window1.xaml.htm
有一点Xslt的意思,比如使用了模版以及标准的XPath
-----------------------Window1.xaml--------------------------
None.gif
None.gif
<
StackPanel
None.gif  
xmlns
="http://schemas.microsoft.com/winfx/avalon/2005"
None.gif  xmlns:x
="http://schemas.microsoft.com/winfx/xaml/2005"
None.gif  Background
="Cornsilk"
None.gif  
>
None.gif
None.gif   
<
StackPanel
.Resources
>
None.gif    
<
XmlDataProvider 
x:Key
="BookData"
 XPath
="/Books"
>
None.gif      
<
Books 
xmlns
=""
>
None.gif        
<
Book 
ISBN
="0-7356-0562-9"
 Stock
="in"
>
None.gif          
<
Title
>
XML in Action
</
Title
>
None.gif          
<
Summary
>
XML Web Technology
</
Summary
>
None.gif        
</
Book
>
None.gif        
<
Book 
ISBN
="0-7356-1370-2"
 Stock
="in"
>
None.gif          
<
Title
>
Programming Microsoft Windows With C#
</
Title
>
None.gif          
<
Summary
>
C# Programming using the .NET Framework
</
Summary
>
None.gif        
</
Book
>
None.gif        
<
Book 
ISBN
="0-7356-1288-9"
 Stock
="out"
>
None.gif          
<
Title
>
Inside C#
</
Title
>
None.gif          
<
Summary
>
C# Language Programming
</
Summary
>
None.gif        
</
Book
>
None.gif        
<
Book 
ISBN
="0-7356-1377-X"
 Stock
="in"
>
None.gif          
<
Title
>
Introducing Microsoft .NET
</
Title
>
None.gif          
<
Summary
>
Overview of .NET Technology
</
Summary
>
None.gif        
</
Book
>
None.gif        
<
Book 
ISBN
="0-7356-1448-2"
 Stock
="out"
>
None.gif          
<
Title
>
Microsoft C# Language Specifications
</
Title
>
None.gif          
<
Summary
>
The C# language definition
</
Summary
>
None.gif        
</
Book
>
None.gif      
</
Books
>
None.gif    
</
XmlDataProvider
>
None.gif
None.gif    
<
DataTemplate 
x:Key
="BookDataTemplate"
>
None.gif      
<
TextBlock 
FontSize
="12"
 Foreground
="Red"
>
None.gif        
<
TextBlock
.Text
>
None.gif          
<
Binding 
XPath
="Title"
/>
None.gif        
</
TextBlock.Text
>
None.gif      
</
TextBlock
>
None.gif    
</
DataTemplate
>
None.gif  
</
StackPanel.Resources
>
None.gif
None.gif  
<
TextBlock 
FontSize
="18"
 FontWeight
="Bold"
 Margin
="10"
None.gif    HorizontalAlignment
="Center"
>
XML Data Source Sample
</
TextBlock
>
None.gif  
<
ListBox
None.gif    
Width
="400"
 Height
="300"
 Background
="Honeydew"
None.gif    ItemsSource
="{Binding Source={StaticResource BookData}, XPath=Book}"
None.gif    ItemTemplate
="{StaticResource BookDataTemplate}"
/>
None.gif 
None.gif
</
StackPanel
>

转载于:https://www.cnblogs.com/civ3/archive/2006/02/06/325975.html

你可能感兴趣的文章
try_module_get和module_put【转】
查看>>
Java刷题知识点之什么是cookie、什么是session、cookie和session有什么区别
查看>>
iOS: 复选框使用---第三方框架SSCheckBoxView-master
查看>>
美化Windows Mobile上的自定义ListView
查看>>
Hdu-1565 电网接入(1) (国家压缩dp获得冠军
查看>>
复杂进销存样例
查看>>
07. Web大前端时代之:HTML5+CSS3入门系列~H5 地理位置
查看>>
ArcGIS Server 开发系列(三)--漫游 Graphics data sources
查看>>
导入HDFS的数据到Hive
查看>>
Microsoft Windows Workflow Foundation 入门:开发人员演练
查看>>
RHEL系统下安装atlassian-jira-5
查看>>
1.5 MySql建表
查看>>
JIT与可见性
查看>>
java中用中国网建提供的SMS短信平台发送短信
查看>>
rails中validates_confirmation_of验证方法无效的解决办法
查看>>
Qt Creator介绍
查看>>
MS SQL 迁移数据库文件
查看>>
Design Pattern: Adapter 模式 - Object Adapter
查看>>
Robot Framework自动化测试(三)---Selenium API
查看>>
解密短信木马为何屡杀不尽--android手机短信木马的攻与防
查看>>