Posted By: jh71283 | Aug 29th @ 1:00 AM
page 1 of 1
Comments: 12 | Views: 769
jh71283
jh71283
Throw new System.Beverage. OutOfCoffeeException​()
I have set up a DependencyProperty, and bound a label to it.

On my class I implement INotifyPropertyChanged, and in the Set method of the DP, I call NotifyPropertyChanged.

However it's pretty slow, like it will take 2 or 3 seconds to change the label.

I know that it is not a delay in sending the notify, because I cheated and set the label from codebehind on the line After the notify, and it updated immediately, so it does seem to be the databinding update that it taking the time Sad

stevo_
stevo_
Casablanca != Manchester
Could you possibly show some code?
DPs do their own change notification.  You shouldn't be using INotifyPropertyChanged.
stevo_
stevo_
Casablanca != Manchester

The getter and setter should be using the DependencyProperty as a key on the DependencyObject (of which Window is)..

Something like:

public static readonly DependencyProperty SomethingProperty = DependencyProperty.Register("Something", typeof(int), etc)

public int Something
{
  get
  {
    return (int)GetValue(SomethingProperty);
  }
  set
  {
    SetValue(SomethingProperty, value);
  }
}

edit: added readonly

Yeah, I didn't read his code, only the first post, where it was obvious what at least some of his problem is.  Sounds like the OP doesn't yet understand DPs.  I'd suggest focusing on the documentation of DPs for a while, or better yet, picking up a WPF book and reading about the concept.
stevo_
stevo_
Casablanca != Manchester

Yes sorry I didn't mean to quote you, still not used to channel9s reply buttons yet.. and you are correct the op does sound like he's new to the dependency system but code is so much easier to read-debug.. english is overrated and verbose Wink

stevo_
stevo_
Casablanca != Manchester
Well you use INotifyPropertyChanged on business objects (those that cannot or shouldn't be a dependency object), it lets them work nicely with a lightweight interface.. the blog post is interesting though, using linq expressions to specify the property that changed.. would help with refactoring and avoiding bugs.. not sure if it has any realistic perf hits..

I would suggest stepping through the program when you are changing the object because I've not heard of any issues myself.. this could well be related to something else.
vesuvius
vesuvius
Everyone has talent at twenty-five. The difficulty is to have it at fifty.
INotifyPropertyChanged implements a delegate that has a string as a parameter. If he did not want to use the INotifyPropertyChanged interface, why not create his own delegate that passes in refactorable data types instead of strings?

 I hate using strings as well, and almost always use enums in their place. You can then pass these user defines types how ever many you need into the delegate you create. Problem solved.
Because such a delegate wouldn't be used by the databinding framework.  Problem not solved.