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. WCF and WF
  4. NotifyPropertyChange makes me crazy

NotifyPropertyChange makes me crazy

Scheduled Pinned Locked Moved WCF and WF
wpfwcfdesignhelpquestion
4 Posts 2 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
    mikla521
    wrote on last edited by
    #1

    Hi! I have a quite complex binding structure. In the first place I have 4 classes. Class1 contains a List<Product> and Product contains several members. The other classes we can leave.. The UI has a Listbox(productListBox) where 2 members from Product are displayed. Works fine. Then, outside the listbox, I have one textbox for each of the product members and displays data from the selected listboxitem. I have set UpdateSourceTrigger=PropertyChanged. And that works fine as well. Seems like a nice working app. But now the tricky part: If I change the text in a TextBox I not only want the Listbox to update but also set a parameter anywhere to keep record if there has been a change. I need to use UpdateSourceTrigger=PropertyChanged otherwise if I save the data before the textbox lose focus I miss the changes. Have tried to write an own OnPropertyChanged event without success. With that I can set my parameter but then I lost the immediate listbox update, well, that part don't update at all then. Ideas? <TextBox Style="{StaticResource InfoTextBox}" Height="23" Name="textBox_Rev" DataContext="{Binding ElementName=productListbox, Path=SelectedItem}" Text="{Binding Path=ProductId, UpdateSourceTrigger=PropertyChanged}" //> public void OnPropertyChanged(PropertyChangedEventArgs e) { if (PropertyChanged != null) { PropertyChanged(this, e); IsChanged = true; // I also want this to be true if changes has occured }} In other words. I need a bool to see if data has changed when I close the app or want to load new data and request a save in case. Is there some way to sort of add a second OnPropertyChange or something? Help someone? :)

    M S 2 Replies Last reply
    0
    • M mikla521

      Hi! I have a quite complex binding structure. In the first place I have 4 classes. Class1 contains a List<Product> and Product contains several members. The other classes we can leave.. The UI has a Listbox(productListBox) where 2 members from Product are displayed. Works fine. Then, outside the listbox, I have one textbox for each of the product members and displays data from the selected listboxitem. I have set UpdateSourceTrigger=PropertyChanged. And that works fine as well. Seems like a nice working app. But now the tricky part: If I change the text in a TextBox I not only want the Listbox to update but also set a parameter anywhere to keep record if there has been a change. I need to use UpdateSourceTrigger=PropertyChanged otherwise if I save the data before the textbox lose focus I miss the changes. Have tried to write an own OnPropertyChanged event without success. With that I can set my parameter but then I lost the immediate listbox update, well, that part don't update at all then. Ideas? <TextBox Style="{StaticResource InfoTextBox}" Height="23" Name="textBox_Rev" DataContext="{Binding ElementName=productListbox, Path=SelectedItem}" Text="{Binding Path=ProductId, UpdateSourceTrigger=PropertyChanged}" //> public void OnPropertyChanged(PropertyChangedEventArgs e) { if (PropertyChanged != null) { PropertyChanged(this, e); IsChanged = true; // I also want this to be true if changes has occured }} In other words. I need a bool to see if data has changed when I close the app or want to load new data and request a save in case. Is there some way to sort of add a second OnPropertyChange or something? Help someone? :)

      M Offline
      M Offline
      mikla521
      wrote on last edited by
      #2

      Or if I put it like this: How do I support UpdateSourceTrigger=PropertyChanged in my custom OnPropertyChanged?

      modified on Friday, April 10, 2009 11:51 AM

      1 Reply Last reply
      0
      • M mikla521

        Hi! I have a quite complex binding structure. In the first place I have 4 classes. Class1 contains a List<Product> and Product contains several members. The other classes we can leave.. The UI has a Listbox(productListBox) where 2 members from Product are displayed. Works fine. Then, outside the listbox, I have one textbox for each of the product members and displays data from the selected listboxitem. I have set UpdateSourceTrigger=PropertyChanged. And that works fine as well. Seems like a nice working app. But now the tricky part: If I change the text in a TextBox I not only want the Listbox to update but also set a parameter anywhere to keep record if there has been a change. I need to use UpdateSourceTrigger=PropertyChanged otherwise if I save the data before the textbox lose focus I miss the changes. Have tried to write an own OnPropertyChanged event without success. With that I can set my parameter but then I lost the immediate listbox update, well, that part don't update at all then. Ideas? <TextBox Style="{StaticResource InfoTextBox}" Height="23" Name="textBox_Rev" DataContext="{Binding ElementName=productListbox, Path=SelectedItem}" Text="{Binding Path=ProductId, UpdateSourceTrigger=PropertyChanged}" //> public void OnPropertyChanged(PropertyChangedEventArgs e) { if (PropertyChanged != null) { PropertyChanged(this, e); IsChanged = true; // I also want this to be true if changes has occured }} In other words. I need a bool to see if data has changed when I close the app or want to load new data and request a save in case. Is there some way to sort of add a second OnPropertyChange or something? Help someone? :)

        S Offline
        S Offline
        sivaddrahcir
        wrote on last edited by
        #3

        Would it be possible to change UpdateSourceTrigger to Explicit, wait for TextChanged events on your TextBox, do your custom logic, and then call UpdateSource() yourself?

        Blog: http://windowsclientdevelopment.spaces.live.com FAQs: http://windowspresentationfoundation.wikispaces.com http://windowsmobile.wikispaces.com http://vsto.wikispaces.com

        M 1 Reply Last reply
        0
        • S sivaddrahcir

          Would it be possible to change UpdateSourceTrigger to Explicit, wait for TextChanged events on your TextBox, do your custom logic, and then call UpdateSource() yourself?

          Blog: http://windowsclientdevelopment.spaces.live.com FAQs: http://windowspresentationfoundation.wikispaces.com http://windowsmobile.wikispaces.com http://vsto.wikispaces.com

          M Offline
          M Offline
          mikla521
          wrote on last edited by
          #4

          Seems like I'm not in full control here :) All of a sudden it works fine.... Yes, I was thinking in the same way as you but don't need that anymore. Thanks anyway :)

          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