Archive for June, 2006

June CTP Changes to Control Widths and Heights

Wednesday, June 28th, 2006

As we get nearer to finally shipping V1, we’ve been pretty hardcore about minimizing the number of breaking changes that we let into the product.  Most of the changes we make these days are straight bug fixes or performance optimizations.  That said, among the more impactful changes that we made from Beta 2 to June CTP is the removal of a series of triggers in our control styles that set the MinWidth and MinHeight properties on the controls.

The Old Behavior 

These triggers, which existed in the templates for many of our controls,ensured a “default” sized control when no explicit width or height had been set.  The result was that a plain Button tag produced a button that was 75×23. 

Originally, we were just setting the MinWidth and MinHeight properties directly, but they were preventing people from changing the size of the control below to be smaller than the default size, a pretty agregious bug.

The New Behavior

We removed these triggers. Now, a plain button tagwill produce a button that is approximate 4×4 (as a result of the borders and padding on the control itself). It will now be necessary for developers to set a width and a height on the button directly. 

Motivation for this Change

We saw multiple problems resulting from the old behavior. Fundamentally, those triggers were overloading the meaning of the value “Auto” in a way that produced inconsistent and problematic behaviors. Specifically:

1. Problems related tooling. Feedback from our tooling partners was clear that the behavior was extremely difficult to tool. The triggers forcing them to write special case code and even with that, there were certain design time sitautions that caused a control to potentially jump around the scene depending on how it was positioned within the designer.

2. Bugs related to styling the MinWidth / MinHeight property The old behavior had the side effect of making it impossible for a user to set MinWidth or MinHeight properties from a style. This was because our triggers were declared with the template which took precedent over the style.

3. Inconsistent layout experience between controls and other elements such as shapes and panels. Finally, controls were the odd man out in terms of layout. No other elements in the platform had this special sizing behavior.

Workarounds

Now, controls will behave like other elements in the platform. The simple workaround for this change is to use a style or local value to set the correct layout properties as necessary. You may, for example, want to explicitly set the MinWidth or MinHeight directly on the controls you use now.

HandDrawnShapes

Tuesday, June 27th, 2006

I usually use time on a plane to write code that I otherwise wouldn’t get to write.  TimelinePanel (soon to be posted) and the ShinyOrangy styles are both examples of plane samples. 

Well, I’ve been flying a lot lately and plane time lately has been committed to my favorite project yet, HandDrawnShapes which is the cullmination of 27 hours in the air.

HandDrawnShapes is a collection of 3 elements (HandDrawnRectangle, HandDrawnEllipse and HandDrawnBorder) which are designed use a slightly flawed geometry and look kind of like they could have been drawn by hand.  They derive from their platform counterparts, so you can use them just like you would use a Rectangle, Ellipse or Border.  Actually, I guess that HandDrawnRecangle and HandDrawnEllipse both derive from Shape so there is probably something that you can’t do, but close enough.

For now, you can download the source here.  Or, if you just want to experment, you can get a .dll and some xaml here.  These run on Beta2 bits.  Unfortunately, they haven’t been updated for the June CTP yet, but if you get the source you should be able to compile to JuneCTP without any issues (though I haven’t tried it).  Finally, you can get the documentation as an XPS document, or as a PDF. 

I’ve been wanting to do this for over a year.  When we went to FITC in 2005, we saw a lot of designers experimenting with this kind look and I got really excited about it.  Unfortunately, though, the idea dropped off my radar after the confernence until just a few months ago wen Fil Fortes reminded me of the idea.  Thanks for the reminder Fil.  Hope you’re having fun at the World Cup.

Do check out the docs.  These come with a lot of tweakability.  The new properties  you have at your disposal include: Randomness, Messiness, StrokeOffsetRandomness, Seed and ScaleToBounds.  Click the image below to get a preview of what these do.

 

Samples

Wednesday, June 21st, 2006

A number of people have requested new or updated versions of samples.  I’ll be post those and some cool new stuff in the next couple of days on the new WPF community site.

Comments

Wednesday, June 21st, 2006

I just uncovered a number of legitimate comments that had been marked as spam.  For some reason, I get a ton of spam on this site so I filter it pretty aggressively.  I’ve restored and approved the comments I caught.  If for some reason your comments haven’t been approved, please repost or let me know.  Thanks.