WPF WTF
My personal WPF WTF list has grown steadily since I started to work with WPF. In my opinion, WPF is filled with bad naming conventions and inconsistencies. Here are some examples.
Border
Let’s start with the Border
control, which can have…a background. That isn’t
just bad design. To me, this is a prime indication that something isn’t right.
To me, a border is something that can be applied to a graphical component and can have a line width and a color. It may be thin, thick, green, aquatic…I don’t care. That is what a border is all about in web, open gl…and Windows Forms.
So, why change the border concept in WPF? Why not call it something else? In my opinion, all the examples below would be better than Border:
- Panel
- Container
- Box
- Div (yeah, even Div would be better than Border)
- SurrounderThingie
- Kwanzabalubah
By naming this UI component Border, Microsoft changes the meaning of an already established concept. DO NOT CHANGE THE MEANING OF AN ALREADY ESTABLISHED CONCEPT!
CheckBox
Let’s continue with the CheckBox
control. A checkbox is something that we have
come to know as a UI control that can be either checked or unchecked. It maps
beautifully to a boolean value.
Except in WPF, where the IsChecked property is a nullable bool that can either be:
- Checked
- Unchecked
- Undetermined
The undetermined state comes from having a nested collection of checkboxes, where some are checked and some are unchecked. I think that this nesting should not affect the checked property. Instead, this property should reflect on whether or not the user has checked the box (which is what 99% of the ux scenarios will be like) and instead have an optional property to check the state of nested checkboxes.
If Microsoft wanted to change this convention, they should have introduced a new UI control (it could even inherit a regular CheckBox). It could have been called:
- HierarchicalCheckboxCollection
- NullableCheckBox
- FuzzyCheckBox
- CheckBoxGoodForSwedishDecisionMakersWhoDoNotWantToMakeADecision
- NotReallyACheckBox
Microsoft once again changes the meaning of an already established concept. DO NOT CHANGE THE MEANING OF AN ALREADY ESTABLISHED CONCEPT!
Bonus content
As a gift for putting up with my rant, here’s a nice CheckBox
extension:
public static bool IsChecked(this CheckBox checkBox)
{
return checkBox.IsChecked.HasValue && checkBox.IsChecked.Value;
}
Enjoy 🙂