+1 Resharper. That's exactly my process for creating those properties. One
day I'll actually write a propOp live template to do the rest of it for me.
I think that everytime I create a property...

On Fri, May 28, 2010 at 2:32 PM, Steven Nagy <[email protected]>wrote:

> I might add, that even if you don’t want to introduce Post# then the simple
> base class + Resharper combination is pretty good.
>
> For example, your base class has some methods for raising property changed
> events. Then your ViewModel needs a property for first name.
>
> You use the “prop” code snippet, this expands out very quickly to:
>
>
>
> public string FirstName { get; set; }
>
>
>
> Then ALT+Enter with Resharper lets you convert to backing field in total 3
> keystrokes:
>
>
>
>         private string _firstName;
>
>         public string FirstName
>
>         {
>
>             get { return _firstName; }
>
>             set { _firstName = value; }
>
>         }
>
>
>
> Then a single call to property changed:
>
>
>
>         private string _firstName;
>
>         public string FirstName
>
>         {
>
>             get { return _firstName; }
>
>             set { _firstName = value; PropertyChanged("FirstName"); }
>
>         }
>
>
>
> Not so bad, very minimal keystrokes.
>
> *Steven Nagy
> *Readify | Senior Developer
>
> M: +61 404 044 513 | E: [email protected] | B: azure.snagy.name
>
>
>
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *Steven Nagy
> *Sent:* Friday, 28 May 2010 4:25 PM
> *To:* ozSilverlight
> *Subject:* RE: Lots of bind/notify classes
>
>
>
> Check out Post#:
>
> http://www.sharpcrafters.com/postsharp/documentation/getting-started
>
>
>
> Example:
>
>
> http://ruskin-dantra.blogspot.com/2009/03/inotifypropertychanged-made-easier.html
>
> Not sure if this works in Silverlight land though.
>
> *Steven Nagy
> *Readify | Senior Developer
>
> M: +61 404 044 513 | E: [email protected] | B: azure.snagy.name
>
>
>
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *Greg Keogh
> *Sent:* Friday, 28 May 2010 4:18 PM
> *To:* 'ozSilverlight'
> *Subject:* Lots of bind/notify classes
>
>
>
> *Look Dave, I can see you're really upset about this. I honestly think you
> ought to sit down calmly, take a stress pill, and think things over* – HAL
> (2001)
>
>
>
> I was wondering if anyone has found a nice way of creating/managing lots of
> classes that are suitable for binding and implement INotifyPropertyChanged.
> As you know, you have to keep coding properties like this:
>
>
>
> public string CompanyName
>
> {
>
>     get {return this.companyNameValue;}
>
>
>
>     set
>
>     {
>
>         if (value != this.companyNameValue)
>
>         {
>
>             this.companyNameValue = value;
>
>             NotifyPropertyChanged("CompanyName");
>
>         }
>
>     }
>
> }
>
>
>
> You can create a  simple base class to factor out the event, but not much
> else, as there is no way I know of to intercept any arbitrary property
> setter and add custom processing. Is that right?! Coding the above skeleton
> dozens or hundreds of times gets tedious and I’m hoping there’s a better
> way. I did consider using a T4 generator to spit out the classes, but that’s
> an obtuse way around the problem and will require extra research time (but I
> see others have done it already).
>
>
>
> I have dozens of existing classes with dozens of properties and I’d like to
> use them for binding, but I’d have to expand every property to be like the
> same above, which would be hell.
>
>
>
> Greg
>
>
>
> _______________________________________________
> ozsilverlight mailing list
> [email protected]
> http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight
>
>
_______________________________________________
ozsilverlight mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight

Reply via email to