博客
关于我
强烈建议你试试无所不能的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

你可能感兴趣的文章
虚拟机安装的UBUNTU全屏的方法:
查看>>
java虚拟机类加载器
查看>>
ASP.NET状态管理之八(会话Session)
查看>>
background
查看>>
转载:大型网站架构演变和知识体系
查看>>
set集合
查看>>
SVN服务器的搭建和使用
查看>>
mvc中枚举的使用和绑定枚举值到DropDownListFor
查看>>
多目标跟踪的评价指标
查看>>
python 生成器
查看>>
HTTPS(SSL)详解以及PHP调用方法
查看>>
突发小事件,USB接口问题
查看>>
Nginx负载均衡配置实例详解
查看>>
L1-009. N个数求和
查看>>
实参传递不当导致的运行时错误
查看>>
PHP生成静态html文件 的三种方法
查看>>
sqlserver 批量删除存储过程(转)
查看>>
自建型呼叫中心
查看>>
Inno setup中定制安装路径
查看>>
要懂得对你的老板好一点!
查看>>