Archive

Archive for January, 2011

Sample ViewModelBase w/ INotifyPropertyChanged support

January 23rd, 2011 2 comments

A sample for both magic string and expression based OnProperyChanged() methods.

 

Sample:

public class ViewModelBase : INotifyPropertyChanged
{
  public event PropertyChangedEventHandler PropertyChanged = delegate { }; 

  public void OnPropertyChanged(String propertyName)
  {
    var handler = PropertyChanged;
    if ( handler != null )
      handler(this, new PropertyChangedEventArgs(propertyName));

  }

  public void OnPropertyChanged<TProperty>(Expression<Func<TProperty>> property)
  {
    var lambda = (LambdaExpression)property;
    MemberExpression memberExpression;

    if ( lambda.Body is UnaryExpression )
    {
      var unaryExpression = (UnaryExpression)lambda.Body;
      memberExpression = (MemberExpression)unaryExpression.Operand;
    }
    else
    {
      memberExpression = (MemberExpression)lambda.Body;
    }
    OnPropertyChanged(memberExpression.Member.Name);
  }
}

 

Read more…

Faking an image roll-over in WPF

January 17th, 2011 No comments

Problem:

I have an image in a button.  I’d like the image to change or toggle when the user clicks the button just like I can do with JavaScript.  You remember JavaScript…  Don’t you?  Not jQuery, but real JavaScript.  <sigh>

Anyway.  Here are a couple solutions that I worked out.     

Read more…

‘That’ itch

January 15th, 2011 No comments

KTM SuperDuke with Great BasinLast month, I went to the Cycle World Motorcycle Expo

I’ve been watching Dakar

I’ve been reading articles on the new Yamaha Super Ténéré and Triumph Tiger 800 and 800 XC

I started playing with the Giant Loop Great Basin bag I got for x-mas. 

I’ve spent hours just staring at my bikes, lost in random thoughts of storage capacity, cold/rain protection, helmets and body armor, mounts for my new Spot II GPS messenger, throttle control and speeding ticket avoidance.

I guess you could say I’ve got that itch.  Even with cold and rainy weather we’ve been having lately, I’m itching to get back on a bike.  I’m itching for a few days away from everything.  I’m itching to disconnect from my hyper-connected life.  I’m itching to focus my attentions on lean angles and hitting my corner markers.   

Standing in my garage, watching the rain continue to fall, I wait.

 

In the meantime, maybe I’ll go surfing in Lahaina.