My Development Notes

By Haemoglobin
1/28/2012 (revision 16)

MVVM

INotifyPropertyChange vs DependencyProperty

Typically, you'll use DPs when working with UI elements (ie: making a control), and INotifyPropertyChanged whenever working with classes that are part of your application logic.

The reason for this is mainly to separate the View code from the application logic. While you can use DPs in application code, doing so has some disadvantages - it ties your application code to the UI platform in question (ie: WPF). INotifyPropertyChanged doesn't take WPF as a dependency, so you can write your application/business logic/model code without taking a WPF dependency.

In addition, DPs are much more difficult to "get right" - this is especially true when writing business logic, as you typically want custom code in your property setter. That being said, if you're using data binding, the setter is never called in a DP, so you need to use the property changed metadata callbacks, which makes your code far more complicated.

http://social.msdn.microsoft.com/Forums/ar-SA/wpf/thread/a4a5a46f-ec4d-433e-b861-706d13bf9de5

Controls

Layout

  • Grid
  • Canvas
  • StackPanel
  • Resources 1, 2

Data Lists

  • ItemsControl
    • ListBox
    • ComboBox

User Controls

  • Consider using Weak Event Manager to reduce memory leaks (Resource 1, 2)

Useful Links

Debugging WCF Errors

Add to web.config:

<serviceDebug includeExceptionDetailInFaults="True"/>

View WCF communication using Fiddler HTTP Debugger. Creating and Handling Faults in Silverlight

Snippets

<TextBox Text="{Binding ReleaseDate, StringFormat='MMM dd, yyyy', 
                    Mode=TwoWay}" />
<TextBlock Text="{Binding Price, StringFormat='c'}" />

<TextBlock Text="{Binding Developer, TargetNullValue='(None)'}" />
<TextBlock Text="{Binding Publisher, FallbackValue='(Nope)'}" />

<StackPanel.RenderTransform>
  <CompositeTransform 
    ScaleX="{Binding Value,ElementName=stretcher}"
    ScaleY="{Binding Value,ElementName=stretcher}" />
</StackPanel.RenderTransform>

Comments

Powered by BlogEngine.NET 1.6.1.0 | Design by styleshout | Enhanced by GravityCube.net | 1.4.5 Changes by zembian.com | Adapted by HamishGraham.NET
(c) 2010 Hamish Graham. Banner Image (c) Chris Gin