I'm just starting to learn WPF, and I'm trying to use the GridViewRowPresenter inside an ItemsControl to essentially duplicate the functionality of a simple table in HTML. ListView is not suitable as it is interactive (which I don't want). I am attached to a general list of objects of unknown magnitude.
I have a list of a custom object that has two string properties: FirstName and LastName. The following code works:
<ItemsControl Name="myItemsControl">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=FirstName}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
while nothing is displayed:
<ItemsControl Name="myItemsControl">
<ItemsControl.ItemTemplate>
<DataTemplate>
<GridViewRowPresenter>
<GridViewRowPresenter.Columns>
<GridViewColumnCollection>
<GridViewColumn DisplayMemberBinding="{Binding Path=FirstName}"></GridViewColumn>
<GridViewColumn DisplayMemberBinding="{Binding Path=LastName}"></GridViewColumn>
</GridViewColumnCollection>
</GridViewRowPresenter.Columns>
</GridViewRowPresenter>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
I am not sure where to go from here, and I would really appreciate any help! Thanks!
source
share