Brent Stewart

Live life on purpose

The winds of change

Just a few weeks ago I decided that a change in my career path was needed.  I have been working for the same company for over 5 years and have recently been feeling like I was stagnating.  Even though my job provided me opportunities to learn new technologies and to stay near the bleeding edge, I still didn't feel like my career was progressing.  This is the same feeling that always seems to precede a job change for me.  But this time I didn’t want to just sign up with a new company and wait for the feeling to return in a couple of years.  This time I decided that I would take my destiny into my own hands.  I am going independent, well as independent as I can afford to be.  My ultimate goal is to create software products that I can monetize, but until I can depend on my products for income, I will be working as an independent contractor. 

I have wanted to be my own boss for years but I always found an excuse to not take the first step.  I finally decided it was now or never, and never was even more terrifying than the prospect of being out on my own.  So I started the ball rolling and within a couple of weeks I had secured my first development contract, and immediately gave my notice.  So as I wrap up my last few days with my current (and hopefully last) employer, I am looking back at where my career has taken me and have come to some conclusions.

The first thing that I have discovered is that my career has lacked focus and that I have relied on dumb luck to be where I am.  I have had the opportunity to work with a lot of clients in many industries and have learned much over the years, but never have I directed my career with any overarching goals in mind.  Sure I have passed on maintenance developer jobs and have taken jobs because of the technologies or opportunities that they presented, but there was never a clear path or even a real understanding of the end game.  I was experiencing first hand Zig Ziglar’s statement that “If you aim at nothing, you will hit it every time.”

Next, I noticed that I wasn’t working towards the goals that I did have.  In the past I have set some goals for myself and they look great on paper, but goals are just dreams unless you take action on them.  Some of the goals that I had set for myself were not realistic and others were just too vague, and yet others seem achievable, but I have made no action plan to reach them.

The last big item that I realized about myself is that I have let fear guide my career path.  I am not necessarily a bold person who takes unnecessary risks, but I am someone who has had to deal with quite a bit of fear and uncertainty in my personal life.  This is one area where I think my experience works against me as I am now much more capable of seeing the dangers and risks of my choices.

So how does this self-reflection help me?  What changes am I going to make?  Well, first I am going to map out my career goals and know my end game strategy.  Of course I fully expect these goals to change over time, so I need to make sure to revisit them and check that they line up with my expectations.  Secondly, I plan to change how my goals are managed.  I need to review them at least weekly and do a thorough re-evaluation monthly.  I need to align my weekly tasks with my goals and make sure that I am making the needed progress.  Lastly, I need to reinforce my belief that the largest personal growth comes from moving out of your comfort zone.  The best way to do this is to continually force myself to do things outside of my comfort zone.  For one, I have been wanting to do some speaking, so I am planning on volunteering for a talk at my local .NET user group.

I hesitate to publish these personal blog posts, but I figure that there maybe some of you who suffer from the same issues and that reading about my struggles may help in some way.  I also hope to follow up this post with some progress reports so others can see my changes in action.

Add PlaceHolder text to a PasswordBox

Place holder text is UI candy that makes your app feel more polished and helps users better understand what needs to be entered into fields.  I had wanted to add place holder text to my WPF app’s login screen for quite a while, but never seem to find the time.

So today I decided to figure out what needed to be done to make this happen. After some searching and reading, I discovered that there are quite a few examples on how to add PlaceHolder text to TextBox controls, but that adding PlaceHolder text to PasswordBox controls is a little more difficult.  Most  of the examples of adding PlaceHolder text to TextBox controls relied on control triggers that checked the Text property to determine the visibility of the place holder text.  The problem with using this technique on a PasswordBox control is that the PasswordBox does not expose a dependency property for the password value, so there is no simple way to wire a trigger up to the value of a PasswordBox.  After some head scratching and a little more research, I decided that using an Attached Property would allow me to accomplish what I wanted.  First, I created a PlaceHolderHelper class that contains an Attached Property PlaceHolderText and a Dependency Property, HasPassword

public class PlaceHolderHelper : DependencyObject
    #region PlaceHolderText
    public static bool GetPlaceHolderText(DependencyObject obj)
        return (bool)obj.GetValue(PlaceHolderTextProperty);
    public static void SetPlaceHolderText(DependencyObject obj, string value)
        obj.SetValue(PlaceHolderTextProperty, value);
    public static readonly DependencyProperty PlaceHolderTextProperty =
        DependencyProperty.RegisterAttached("PlaceHolderText", typeof(string), 
            new UIPropertyMetadata(string.Empty, PlaceHolderTextChanged));
    private static void PlaceHolderTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        if (!(d is PasswordBox)) return;
        ((PasswordBox)d).PasswordChanged += 
            (sender, args) =>
                var pb  = sender as PasswordBox;
                pb.SetValue(HasPasswordProperty, (pb.Password.Length > 0));
    #region HasPassword
    public bool HasPassword
        get { return (bool)GetValue(HasPasswordProperty); }
        set { SetValue(HasPasswordProperty, value); }
    private static readonly DependencyProperty HasPasswordProperty =
            typeof(bool), typeof(PlaceHolderHelper), 
            new FrameworkPropertyMetadata(false));

This let me bind up a listener to the PasswordChanged event of the PasswordBox so I could track whether a password had been entered or not.  It also gave me the needed Dependency Property to use in my Control Trigger.  Next, I needed to create a Style that overlaid my place holder text over the PasswordBox.

<Style TargetType="{x:Type PasswordBox}">
    <Setter Property="Template">
            <ControlTemplate TargetType="{x:Type PasswordBox}">                    
                <Border Name="MainBorder"
                     Background="{TemplateBinding Background}"
                     BorderBrush="{TemplateBinding BorderBrush}"
                     BorderThickness="{TemplateBinding BorderThickness}">
                        <ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center" Margin="1" />
                            <TextBlock x:Name="PlaceHolder"
                                Text="{TemplateBinding ctrls:PlaceHolderHelper.PlaceHolderText}" 
                                Foreground="LightGray" IsHitTestVisible="False" 
                                HorizontalAlignment="Left" VerticalAlignment="Center" Margin="4,0,0,0"/>
                    <Trigger Property="ctrls:PlaceHolderHelper.HasPassword" Value="True">
                        <Setter TargetName="PlaceHolder" Property="Opacity" Value="0" />

This is a very simplified style, but I wanted to boil this all down to the simplest example I could so you could see how this technique works.  Now all I had to do was declare a PasswordBox and set the PlaceHolderText.

<StackPanel VerticalAlignment="Top" Orientation="Horizontal" Margin="5">
  <PasswordBox Width="120" Height="24" ctrls:PlaceHolderHelper.PlaceHolderText="Enter your password" />
  <PasswordBox Width="140" Height="24" ctrls:PlaceHolderHelper.PlaceHolderText="Enter your secret phrase"  Margin="5"/>
  <Button Content="Submit" Width="50" Height="24" />

Here are the results, first with no text entered

and finally when entering text

Teaching my daughter to type

My 10 year old daughter loves to write and is a creative and imaginative story teller.  I want her to be able to share her stories with others and luckily we live in a time and age where that is a simple matter. Her typing skills are the main thing that is keeping her from being able to share her stories, so I have decided that I would try to teach her to type. I have found that there are quite a few free websites dedicated to learning to type and they seem to wok well. The only issue that I have found is that most of the sites use Flash for the training, so learning on my Surface RT is out. I guess it is time to either find a good typing program for Windows RT, or maybe this is an opportunity for making an app. Let me know if you have any suggestions for good typing programs for kids.

Surface Pro…Does it pass the WAF?

I stopped by the local Microsoft store today at lunch and tried out the Surface Pro and I must say that it was quite a nice piece of hardware. I already have the Surface RT and have been happy with the purchase overall. My wife on the other hand has been less impressed because she keeps running into things that the Surface either can’t do, or doesn’t do well. One, she keeps finding websites that don’t play nice with touch screen only interactions, (hover menus, sliders, etc.), and two, she uses sites that need to be able to run flash. She had all these complaints on her previous iPad, but I was hoping the Surface RT would fix some of this. But alas, there are still too many sites that don’t play nice with tablets. My wife keeps insisting that a laptop is what she needs because it is a real computer and won’t have the same limitations, and while I agree that it should fix those issues, it feels like a poor fit for someone who mostly consumes information.  So the $64,000 question is, does a Surface Pro tablet fix the issues, or will she still see it as just a tablet?

Use the Snipping Tool to make life easier

I knew about the Snipping Tool in Windows, but for some reason I never thought much about it until recently when a friend reminded me when he heard all the steps I was going though to get a screen capture. I was answering a question from StackOverflow, and I was trying to show some XAML output, so here is what I did to capture the output:

  1. Take a screen shot by pressing Alt+Print Screen (captures the active window to the clipboard)
  2. Open a graphics application (Paint.NET or Photoshop)
  3. Paste the clipboard contents into a new document
  4. Crop to the section of the screen I want to capture
  5. Save results to a file
  6. Insert file into my response

The same process using the Snipping Tool in Windows goes like this:

  1. Open Snipping Tool
  2. Select screen area I want to capture (the selection is inserted into the clipboard automatically if that is all you need)
  3. Save results to file
  4. Insert file into my response

Ah, much better.  This may not sound like a lot of savings, but it takes away the feeling of having to work to get what I want. There is a much better chance of me taking time to grab a capture when I know that it is this simple, and that increases the quality of my communications and gives me a greater chance of being understood. The next time you need to capture something from your screen, don’t forget the Snipping Tool.