[WPF] 在ListView中填充Mockup数据
用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>
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>