Question

I'm trying to create a Table inside a FlowDocument inside a FlowDocumentPageViewer, as seen in this tutorial. I've never created a table in WPF before, and I was expecting there to be an ItemsSourceproperty to which I could bind, like with a ListBox. I want to customize the template for each row, and I want each row's source to be an item in a collection that I pass to the entire table. So I'll have a List<MyClass> instance that would be passed to the table, and each row would show a single MyClass. How can I do that? Do I not want to use a Table within a FlowDocument? The reason I wanted to use some kind of tabular format is so that I can have a single row of column names that applies to all the rows.

Was it helpful?

Solution

I think what I wanted was to use ListView, thanks to this tutorial:

<ListView Grid.Row="0" ItemsSource="{Binding Path=MyList}" MinWidth="400"
    MinHeight="200">
    <ListView.View>
        <GridView>
            <GridView.Columns>
                <GridViewColumn
                    DisplayMemberBinding="{Binding Path=MyFirstField}"
                    Header="First Field"/>
                <GridViewColumn
                    DisplayMemberBinding="{Binding Path=MySecondField}"
                    Header="Second Field"/>
            </GridView.Columns>
        </GridView>
    </ListView.View>
</ListView>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top