Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4067634
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:16:28+00:00 2026-05-20T16:16:28+00:00

To date every ListView I’ve had I just set ItemSource={Binding} in my Xaml and

  • 0

To date every ListView I’ve had I just set ItemSource={Binding} in my Xaml and then in the .CS file I say listview.datacontext = myobject and the view loads just fine. But now I need to have a list that updates as the data updates as well. So after some research I discovered ObservableCollections and rewrote my code to use that. But I can’t get my data to display when setting the listview to my dataobject.

My Xaml:

            <ListView ItemsSource="{Binding Tests}" Name="DataCompareTests" Margin="0,0,5,0" Grid.Column="0">
                <ListView.View>
                    <GridView>
                        <GridViewColumn Header="TestCase" Width="200" DisplayMemberBinding="{Binding name}" />
                    </GridView>
                </ListView.View>
            </ListView>

My Xaml.cs:

readonly DataCompare dataCompare = new DataCompare();

public void Execute_Click(object sender, RoutedEventArgs e)
    {

        var Tests = new ObservableCollection<TestCases>();
        Tests = dataCompare.LoadTestCases();  //located in another class file
        //DataCompareTests.DataContext = Tests;
    }

If I remove the “Tests” part of the binding in my Xaml and remove the comments from the .DataContext line above, the view displays the correct information. However it’s my assumption that if I want my view to update as the data does I need to specify my object in the binding. How do I properly set that? I can’t seem to find the correct answer.

Thanks,

Jason

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T16:16:28+00:00Added an answer on May 20, 2026 at 4:16 pm

    It would appear my concerns were pointless and I WAS doing this the proper way in the first place.

    According to MSDN:

    “However, if you are binding to an object that has already been created, you need to set > the DataContext in code, as in the following example.
    …
    myListBox.DataContext = myDataSet;”

    My object was already created, and I did set the DataContext in the code. All I had to do was leave the ListView ItemSource as {Binding} and each time I added to the Tests object, the list updated..

    I can’t believe I spent an entire day doubting I was doing this correctly without moving forward to check. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to display price of item for every date in the month. The
I am trying to populate a date table which contains every date for the
I've created a ListView with a GridView component in it. Now trying to fill
I coded an own Adapter and added it to my ListActivity via an ListView.
I'm trying to do a very basic date-difference calculation with javascript, but am getting
I would like to invoke my chrome or firefox browser when a file that
I'd like to know if there is a jar-file out there that could do
With Linq To Sql - what is the best way to update the value
I've written an entire app pretty successfully in Django but I have this nagging
I have a high-demand transactional database that I think is over-indexed. Originally, it didn't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.