Coffeehouse Thread

6 posts

Inconsistency in Silverlight/WPF

Back to Forum: Coffeehouse
  • Sonicflare

    Hi guys,

    I'm creating this topic, not to flame about silverlight/wpf, but to get some ideas, why the property naming in Silverlight and probably WPF is different than in .net and WinForms.

    I really like what Silverlight enables .net devs to quickly write web apps (relative to HTML+JS+CSS junk), but the naming just freaks me out.

    For example:

    IsEnabled when in Winforms you have Enabled.

    HasCloseButton  when in WinForms ControlBox / MaximumBox / MinimumBox

    IsTabStop, TabIndex  instead of TabStop, TabIndex. In Silverlight they are not bundled together. On WinForms they are next to each other on PropertyGrid.

    Content / Header / Text/ instead of Text.

    And Grid.Column / Grid.RowSpan / Grid. etc/ that really bugs me.

     

    This really reminds me of good old VB6 days, when you had Caption / Text / Title  on different controls.

    Do you have any clue, why?

  • W3bbo

    Before getting into the topic I'll just point out that Silverlight is not a tool for making web apps, it's a runtime that runs within a browser that already has the necessary dependencies, it is not vendor-neutral nor universally supported.

     

    .IsEnabled only makes sense for read-only properties. I haven't done much Silverlight/WPF to know if .IsEnabled is read-only or writable.

     

    I gather the .Text property in WinForms is a legacy from the Win32 window's requirement for a "Caption" string, WPF removes that requirement, which gave the control designers more freedom in appropriately naming properties.

     

     

  • DCMonkey

    IsEnabled reads better (ie: FooBar Is Enabled)

    WPF/SL controls can have more than text for content and sometimes more than one "content" property

    Attached properties. They're a way to set properties on a parent element that relate to that child element.

  • vesuvius

    Winforms was finally released 6, or so years ago. The world has changed greatly, and better ways of programming, doing and naming things have resulted in WPF.

     

    In winforms you only have properties, but you have dependency properties in WPF that allow for far greater flexibility. Yes, you can always compare things, and sometimes the older way seems better, but as a package, WPF and WPF/E are acres and acres better.

  • SimonJ

    Prefixing properties with "Is" makes it obvious that they are booleans.

    If you didn't know better, TabStop could be a number and get confused with TabIndex.

    Using IsTabStop instead avoids this problem.

     

    Grouping related properties by category rather than listing them alphabetically brings IsTabstop and TabIndex closer together but the grouping could do with being more granular. The categories are often a little broad.

     

    In Windows Forms, TabStop and TabIndex are usually in the small category Behaviour.

    In WPF, IsTabStop and TabIndex are often in the large category Other.

  • wkempf

    Names like IsEnabled are following the Framework Design Guidelines (http://www.amazon.com/Framework-Design-Guidelines-Conventions-Libraries/dp/0321545613/ref=sr_1_1?ie=UTF8&s=books&qid=1280076371&sr=8-1) which is a very consistent guide for naming. Sorry, W3bbo, I can't agree with you about "Is" names only be read-only.

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.