>{ >var p = this.StatusProgressBar; >p.IsIndeterminate = false; >p.Visibility = Visibility.Visible; >p.Minimum = 0; >p.Maximum = 100; >p.Value = percentage; >} >Of course the argument most often put forward by the VB camp for WITH....ENDWITH is that it reduces the amount of typing required. Which begs the question of why, if that is important, they chose VB in the first place (g,d&r). Here's a clever alternative: http://stackoverflow.com/questions/1063429/equivalence-of-with-end-with-in-c.
public static void With<T>(this T _object, Action<T> _action) { _action(_object); }Which would allow:
this.StatusProgressBar.With(p=> { p.Isdeterminate = false; //etc } );Then again it's no more readable than the locally scoped variable version and is probably less efficient (although potentiallly much more flexible)