不相信你可以很容易地做到这一点,我个人使用的IValueConverter接口DataSet中转换成一个对象,可以在里面管理列。
public sealed class DataSetConverter : IValueConverter
{
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if((DataSet)value != null)
{
// Put logic in here to loop through the columns and create an object to bind to the ListView control.
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
XAML代码
<conv:DataSetConverter x:key="datasetConverter"/>
<ListBox x:Name="listbox1" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ItemsSource="{Binding datasetObject, Converter={StaticResource datasetConverter}}" >
所以数据集不是强类型?所以它是动态的? – 2011-03-24 23:55:30
这是正确的。不是强类型 – 2011-03-24 23:56:50