Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Curios as to why this doesn't work...

Curios as to why this doesn't work...

Scheduled Pinned Locked Moved WPF
wpfcsharpwcfquestion
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Michael Eber
    wrote on last edited by
    #1

    I have a WPF application which contains a ListView defined to show the values for an item in a chart. One of the fields, State, is supposed to change as the charted values cross warning and alarm barriers. I built up the list (which was really only one item) as follows:

     ObservableCollection<LegendValues> itemList = new ObservableCollection<LegendValues>();
     LegendValues item = new LegenValues();
     ... define the initial values ...
     itemList.Add( item );
     myListView.ItemsSource = itemList;
    
    
     // further on in my code
     item.State = "Warn";
    

    I also have the binding set in XAML as TwoWay. When I change the state in the item object, it does not change in the ListView. Is there something I'm missing? Thanks, Michael

    A B 2 Replies Last reply
    0
    • M Michael Eber

      I have a WPF application which contains a ListView defined to show the values for an item in a chart. One of the fields, State, is supposed to change as the charted values cross warning and alarm barriers. I built up the list (which was really only one item) as follows:

       ObservableCollection<LegendValues> itemList = new ObservableCollection<LegendValues>();
       LegendValues item = new LegenValues();
       ... define the initial values ...
       itemList.Add( item );
       myListView.ItemsSource = itemList;
      
      
       // further on in my code
       item.State = "Warn";
      

      I also have the binding set in XAML as TwoWay. When I change the state in the item object, it does not change in the ListView. Is there something I'm missing? Thanks, Michael

      A Offline
      A Offline
      Abhinav S
      wrote on last edited by
      #2

      Michael Eber wrote:

      Is there something I'm missing?

      INotifyProperty perhaps?

      M 1 Reply Last reply
      0
      • A Abhinav S

        Michael Eber wrote:

        Is there something I'm missing?

        INotifyProperty perhaps?

        M Offline
        M Offline
        Michael Eber
        wrote on last edited by
        #3

        Well...according to the documentation all I need are two things. TwoWay link on the binding between the ItemSource object and the ListIndex, and the ObservableCollection. But I can add INotifyProperty and see if that helps.

        P J 2 Replies Last reply
        0
        • M Michael Eber

          Well...according to the documentation all I need are two things. TwoWay link on the binding between the ItemSource object and the ListIndex, and the ObservableCollection. But I can add INotifyProperty and see if that helps.

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          ObservableCollection is only used to tell the binding engine when records have been added or removed from the collection. In order to watch changes to particular properties, you need to use INotifyPropertyChanged and raise the PropertyChanged event.

          "WPF has many lovers. It's a veritable porn star!" - Josh Smith

          As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

          My blog | My articles | MoXAML PowerToys | Onyx

          1 Reply Last reply
          0
          • M Michael Eber

            Well...according to the documentation all I need are two things. TwoWay link on the binding between the ItemSource object and the ListIndex, and the ObservableCollection. But I can add INotifyProperty and see if that helps.

            J Offline
            J Offline
            Jammer 0
            wrote on last edited by
            #5

            Have a read up on MVVM, in particular anything to do with the ViewModel portion of that design pattern and as Pete said it's all about the object INSIDE your ObservableCollection.

            Jammer My Blog | Articles | DMon | SampleSort

            1 Reply Last reply
            0
            • M Michael Eber

              I have a WPF application which contains a ListView defined to show the values for an item in a chart. One of the fields, State, is supposed to change as the charted values cross warning and alarm barriers. I built up the list (which was really only one item) as follows:

               ObservableCollection<LegendValues> itemList = new ObservableCollection<LegendValues>();
               LegendValues item = new LegenValues();
               ... define the initial values ...
               itemList.Add( item );
               myListView.ItemsSource = itemList;
              
              
               // further on in my code
               item.State = "Warn";
              

              I also have the binding set in XAML as TwoWay. When I change the state in the item object, it does not change in the ListView. Is there something I'm missing? Thanks, Michael

              B Offline
              B Offline
              BechBej
              wrote on last edited by
              #6

              try to do add Updatesourcetrigger = Propertychanged to the xaml in addition to the two way, make sure that the object source bound property implement the INotifyPopertyChanged or is a dependency property

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups