Silverlight 数据绑定 :怎样实现数据绑定
2008-10-24 11:47:15 来源:WEB开发网App.xaml:
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="SilverlightTestApp.App"
>
<Application.Resources>
<DataTemplate x:Key="ListBoxDataTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Age}" Margin="20,0" />
<TextBlock Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</Application.Resources>
</Application>
Page.xaml:
<UserControl x:Class="SilverlightTestApp.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<ListBox x:Name="list1" ItemTemplate="{StaticResource ListBoxDataTemplate}">
</ListBox>
</Grid>
</UserControl>
运行后效果一样。
Tags:Silverlight 数据 绑定
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接