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

Let's say I have a table that has user_id, date, score, and every user
I need to go through every row in a table and set every date
I have noticed that regardless of a given script's execution time, every date() call
Every time I need to work with date and/or timstamps in Java I always
Currently, every comment has the same date as the original post. Theme functions PHP:
I am getting a conversion error every time I try to submit a date
i try to build a function that converts every date to a timestamp. JS
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 want to be able to get and set the date using my own

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.