用Blend做Visual Design,常常會遇到不知道如何往ListView裡放假數據的問 題。這時提供一種方法。供大家參考。如果有更簡單的方法,也希望大家不吝賜 教。
代碼如下:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:System;assembly=mscorlib"
x:Class="ListViewData.MainWindow"
x:Name="Window"
Title="Demo Window"
Width="300" Height="300">
<Grid x:Name="LayoutRoot">
<ListView>
<ListView.View>
<GridView>
<GridViewColumn Header="Value"
DisplayMemberBinding="{Binding .}"/>
<GridViewColumn Header="Length"
DisplayMemberBinding="{Binding Length}"/>
</GridView>
</ListView.View>
<ListView.Items>
<s:String>a</s:String>
<s:String>bb</s:String>
</ListView.Items>
</ListView>
</Grid>
</Window>