开发者

Common Programming mistakes for WPF developers to avoid? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly开发者_运维技巧 reopened, visit the help center for guidance. Closed 11 years ago.

what are the common mistake can be avoided by a WPF developer?


I think a big mistake would be to ignore the M-V-VM Pattern that should be used by good developers


Treating it like Windows Forms.. Don't do that.. WPF != WinForms..


Putting code (validation, coercion logic, change notifications, logging, etc) in the getters and setters of dependency properties' corresponding CLR properties, instead of using the PropertyChangedCallback, ValidateValueCallback and CoerceValueCallback.

Normal .NET code can get or set the property values through them, but WPF gets and sets these values by going directly to the backing store.

The CLR wrapper should thus look like this:

public int Prop
{
  get
  {
    /*NOTHING IN HERE*/

    return (int)GetValue(ThingyProperty);
  }

  set
  {
    /*NOTHING IN HERE*/

    SetValue(ThingyProperty, value);

    /*NOTHING IN HERE*/
  }
}


Over-engineering... just because it is possible to do with a complex binding doesn't mean you can maintain it...

EDIT: And doing things in XAML that should be done elsewhere.


Check this out -

What are the most common mistakes made in WPF development? What are the most common mistakes made in WPF development?


  • Treating it like Windows Forms or ASP.NET
  • Ignoring the MVVM Pattern
  • Overusing the MVVM pattern in sake of MVVM pattern
  • Treating it like Silverlight
  • Ignoring XAML coding guidelines -> result in unmaintainable XAML.
  • Ignoring Binding errors in Visual Studio Output
  • Ignoring Designer in Visual Studio (i.e. WPF application blendability)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜