Rediscovering the Obvious

…stumbling in the footsteps of greatness

Archive for August, 2007

Warning: Unexpected WPF focus behavior

without comments

I’ve got a login screen with a TextBox, a PasswordBox, and a Button (yeah yeah, just like everybody else).

Type login, hit tab, type password, hit tab, hit spacebar to click the button. (So far so good)

I did it right, so my new Page opens within my Frame (Yeah, that’s the point)

But, I don’t see any of the controls focused like I’d expect. And hitting tab doesn’t bring the focus into view (Now that’s odd…)

Well, as I discovered today, the button on the previous screen was still focused (Whoa!)

Lesson: When you navigate to a page, set the focus to that page, or have the page set its own focus as appropriate.

 

Written by erwilleke

August 9th, 2007 at 3:29 pm

Posted in Uncategorized

Preventing F10 from opening an application’s menus

without comments

Hopefully you don’t need to do this often, but in our case we have a special hardware integration need to either handle or ignore the F10 key. However, F10 doesn’t generate a KeyDown event with e.Key == Key.F10.

Instead, do this: 

        void Window_KeyDown(object sender, KeyEventArgs e)
        {
            if(e.Key == Key.System && e.SystemKey == Key.F10 )
            {
                e.Handled = true;
            }
        }

Written by erwilleke

August 9th, 2007 at 12:08 pm

Posted in Uncategorized

Software development IS product development

without comments

Great analysis by Corey at http://feeds.feedburner.com/~r/LeanSoftwareEngineering/~3/142106190/

This part especially hits home with how I feel about things I’ve seen (emphasis mine):

“Software methodology’s understanding of the meaning of quality,
reliability, and customer utility is positively retarded in comparison
to the understanding of the broader product development community.”

As he discusses, there are a TON of important lessons being ignored EVERY DAY by software practitioners. This is one of the main reasons why ex-software developers rarely seem to make good project leads… the technology and the details of the technical purity are too important to them. While these aspects ARE critical, there are many much more important lessons to be considered that can be seen by opening your mind to the experiences in product development from across the board. Let the auto industry teach you about user experience, let pharmaceutical companies teach you about design space exploration, let the companies that make implanted pacemakers teach you about quality control, learn how to expand existing systems by looking at the London Underground, learn automation from the post office, and learn interaction design from cell phone companies… all of these nearby, obvious industries have a LOT to offer us, and we ignore it all too often.

What have you done to fix this? This week? Today?
What will you do tomorrow? Next week? Next Month?

How will you contribute to fixing our profession?

Software leadership needs to climb out of its little box and see itself
in the larger context if it ever expects to be taken seriously by other
engineering fields.

Written by erwilleke

August 9th, 2007 at 9:20 am

Posted in Uncategorized

ListView + GridView – Selection == ItemsControl + GridViewHeaderRowPresenter + GridViewRowPresenter

without comments

This is neat. I’ve been annoyed for quite a while that I haven’t figured out how to “enroll” things in a StackPanel into columns for alignment and consistency… I’ve wanted basic control layouts (no sorting, selection, etc) to have a roughly “Gridbased” alignment, but haven’t been able to figure out how to do so without going up to a ListView configured with a GridView, which is too heavy and introduces issues with turning OFF the selection behavior (which, oddly, doesn’t have any properties to disable it that I can find)

Today, trying to figure out how to style the GridView the way I want it, I finally stumbled on to the GridViewHeaderRowPresenter and GridViewRowPresenter. YAY! These two classes allow multiple entities to share a GridViewColumnCollection (as a resource) and (somehow… insert black WPF voodoo magic here) share column and width information. So, my code for a nicely aligned read only grid of controls (the grid has buttons, links, etc on each item) is simple, as follows… after setting it up, all of my data bindings in the CellTemplate resources work just perfectly.

<!– In the Resources –>
     <!– Example cell data template –>
       <DataTemplate x:Key=”lineItemDescriptionTemplate”>
            <TextBlock
                Style=”{StaticResource pageContentTextBlock}”
                VerticalAlignment=”Center”
                Text=”{Binding Path=Description}”
                MinWidth=”150″ />
        </DataTemplate>

        <GridViewColumnCollection x:Key=”gridColumns”>
            <!– Details –>
            <GridViewColumn CellTemplate=”{StaticResource lineItemDetailLinkTemplate}”/>
            <!– Remove –>
            <GridViewColumn CellTemplate=”{StaticResource lineItemRemoveLinkTemplate}”/>
            <!– Image –>
            <GridViewColumn CellTemplate=”{StaticResource lineItemLookupLinkTemplate}”/>
            <!– … –>
        </GridViewColumnCollection>
         <DataTemplate x:Key=”gridRowItemTemplate”>
            <GridViewRowPresenter Columns=”{StaticResource saleGridColumns}” ></GridViewRowPresenter>
        </DataTemplate>

<!– Main page body –>
   <StackPanel DockPanel.Dock=”Top”>
            <GridViewHeaderRowPresenter Columns=”{StaticResource gridColumns}”
                                        ColumnHeaderContainerStyle=”{StaticResource columnHeaderContainerStyle}”
                                        ColumnHeaderTemplate=”{StaticResource columnHeaderTextBlock}”
                                        />
            <ItemsControl x:Name=”_lines2″
                          ItemTemplate=”{StaticResource gridRowItemTemplate}” />
   </StackPanel>

 

 

Written by erwilleke

August 8th, 2007 at 9:47 am

Posted in Uncategorized

Talking about trees

without comments

Sheva’s Techspace is talking about trees at http://shevaspace.spaces.live.com/Blog/cns!FD9A0F1F8DD06954!581.entry

I’ve added a comment with my “work around” to that specific problem, and I’m curious what other people have seen/done.

 

Written by erwilleke

August 7th, 2007 at 8:32 am

Posted in Uncategorized

Too soon! Too soon!

without comments

http://blogs.msdn.com/bharry/archive/2007/08/06/work-item-tracking-enhancements-in-the-aug-rosario-ctp.aspx

This is pure torture… TFS 2008′s still only in beta 2, and he’s already tormenting me with the things that the NEXT version will have, but I can’t have now unless I want to install an early CTP… GROWL!!!!    

[EDIT]

I’m actually quite happy that MS is pushing information out about their products well in advance. This allows companies to plan changes they must and can make to their processes well in advance, vet them out a bit vs. CTP/Beta releases, and be ready to take advantage of releases when they’re available. I’m a HUGE fan of early transparency. However, agreeing a bit with some of the comments at the original post, there are a few thing that would help, especially ways to help filter talk about pre-release versions from live versions in searches (aka WPF vs. Avalon when looking for solutions to problems) and clear channels for discussion regarding specific products/versions (i.e. a link to a forum the devs will monitor in any significant ‘official’ posting about a technology/toolset).

This rant was just my frustration because I’ve deeply wished for the improved work item linking he’s described for quite some time… something about having to do process definition for military and health care work ;)

Written by erwilleke

August 6th, 2007 at 9:37 am

Posted in Uncategorized

Force a WPF DataBinding to Update

without comments

From: http://blogs.msdn.com/jaimer/archive/2007/07/04/forcing-a-wpf-binding-to-refresh.aspx

Now I’ll find it again, since it took me five minutes to find that link even after using it once.

BindingOperations.GetBindingExpressionBase(_dependencyObjectWithBinding, TextBlock.SomeDependencyProperty).UpdateTarget();

 

Written by erwilleke

August 3rd, 2007 at 12:35 pm

Posted in Uncategorized

InputBinding == flexibility

without comments

I was frustrated yesterday because I had 8 different buttons on a screen that were perfect for RoutedUICommand bindings with the CommandParameter set to a different value on each. However, they each also needed a different KeyGesture attached, and as far as I knew yesterday, you only could tie gestures to commands through the Command.InputGestures collection.

Not true!  The following code uses an InputBinding to tie a gesture on a specific control to a RoutedUICommand with a specified CommandParameter. Life is good, off to code!

                InputBinding inBind = new InputBinding(SomeCommand, new KeyGesture(Key.NumPad1));
                inBind.CommandParameter = commandType;
                control.InputBindings.Add(inBind);
 

 

Written by erwilleke

August 3rd, 2007 at 9:11 am

Posted in Uncategorized

Must-Read post

without comments

I’ve been bickering with one of my peers about testability vs. simplicity and extensibility vs. sufficiency, and this article came back to mind. Anybody who hasn’t read it, should. Anybody who has read it should read it again. Where were you before? Where are you now? Where would you like to be? What makes sense for you? Are different projects different? Can a consulting company arbitrate a certain level (CMS? RNO? MAB? B?H?

http://leansoftwareengineering.com/2007/05/22/design-verification-capability-part-1/

 

Written by erwilleke

August 2nd, 2007 at 8:50 am

Posted in Uncategorized

Binding targets must be public?

without comments

It appears so! I had a nice informative binding working in my window’s frame, did some refactoring, and it disappeared. My property accessors just weren’t getting called.  Here’s the interesting code, which was bound using the notation that follows:

        // Local object accessor to make the binding easier
        public RicsUser CurrentUser
        {
            get
            {
                return App.CurrentUser;
            }
        }

        // Local object accessor to make the binding easier
        protected Organization CurrentOrganization
        {
            get
            {
                return App.CurrentOrganization;
            }
        }

 // XAML

<TextBlock
    x:Name=”_userTag”
    Text=”{Binding Path=CurrentUser, Converter={StaticResource UserNameConverter}, ElementName=_RicsMainWindow, Mode=Default}”
/>
 
One gets called, the other doesn’t. Both are bound identically to the TextProperty on a TextBlock. If I change CurrentOrganization from protected to private to internal, still fails. Make it public, everything works.

As an aside, this was the cause of my earlier problem, and my earlier solution can be used as a workaround for this.

Written by erwilleke

August 1st, 2007 at 1:54 pm

Posted in Uncategorized