0

I am trying to put ListView items in my ListView, which is seperated into columns with a GridView object.

I have no idea how to put new items in the columns, and there are not so many useful tutorials on the web.

Here's the XAML code for the ListView:

        <ListView Canvas.Left="200" Canvas.Top="68" Height="138" Name="listView1" Width="444">
        </ListView>

And the GridView is created dynamically:

    public MainWindow()
    {
        InitializeComponent();

        GridView grdView = new GridView();

        GridViewColumn nameColumn = new GridViewColumn();
        nameColumn.DisplayMemberBinding = new Binding("Time");
        nameColumn.Header = "Time";
        nameColumn.Width = 120;
        grdView.Columns.Add(nameColumn);

        GridViewColumn ageColumn = new GridViewColumn();
        ageColumn.DisplayMemberBinding = new Binding("Date");
        ageColumn.Header = "Date";
        ageColumn.Width = 120;
        grdView.Columns.Add(ageColumn);

        listView1.View = grdView;
    }

I want to add some Items into the ListView, how to do that?

1

1 Answer 1

1

You need to bind it to some data

ItemsControl.ItemsSource Property

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.