Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
883 views
in Technique[技术] by (71.8m points)

.net - Multicolumn ListBox in WPF

I have 3 TextBoxes and 1 Button and want to enter each of the the TextBoxes data into a ListBox in separate columns.

I know how to enter data into one column:

listbox1.Items.Add(TextBox1.text);

but how can I enter the data into multiple columns?

I am using .NET WPF. I want to use a ListBox or a ListView.

my window

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You want a ListView instead:

Something like this:

<ListView ItemsSource="{Binding SourceCollection}">
    <ListView.View>
        <GridView>
            <GridViewColumn Header="Test1" DisplayMemberBinding="{Binding Test1}" />
            <GridViewColumn Header="Test2" DisplayMemberBinding="{Binding Test2}" />
            <GridViewColumn Header="Test3" DisplayMemberBinding="{Binding Test3}" />
            <GridViewColumn Header="Button">
                <GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <Button>Button Text</Button>
                    </DataTemplate>
                </GridViewColumn.CellTemplate>
            </GridViewColumn>
        </GridView>
    </ListView.View>
</ListView>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...