What is Lazy Loading?

It’s called lazy loading because, like a lazy person, you are putting off doing something you don’t want to. The opposite is Eager Loading, where you load something right away, long before you need it. If you are curious why people might use lazy loading, consider an application that takes a LOOOOONG time to start. … Read more

WPF CommandParameter is NULL first time CanExecute is called

I was having this same issue while trying to bind to a command on my view model. I changed it to use a relative source binding rather than referring to the element by name and that did the trick. Parameter binding didn’t change. Old Code: Command=”{Binding DataContext.MyCommand, ElementName=myWindow}” New Code: Command=”{Binding DataContext.MyCommand, RelativeSource={RelativeSource AncestorType=Views:MyView}}” Update: … Read more

What are the various WPF binding modes?

OneWay: Use this when you want the bound property to update the user interface. TwoWay: This has the same behavior as OneWay and OneWayToSource combined. The bound property will update the user interface, and changes in the user interface will update the bound property (You would use this with a TextBox or a Checkbox, for … Read more

WPF Bind to itself

Short answer:{Binding} is not a shortcut for “binding to itself” (in the sense of RelativeSource.Self). Rather, {Binding} is equivalent to {Binding Path=.}, which binds to the current source. To elaborate: A binding has a source and a path. You can do a “binding to itself”, for example, by using <myUIControl myProperty=”{Binding RelativeSource={RelativeSource Self}, Path=x}” /> … Read more

What approaches are available to dummy design-time data in WPF?

Using VS2010 you can use Design-Time attributes (works for both SL and WPF). I usually have a mock data-source anyway so it’s just a matter of: Adding the namespace declaration xmlns:d=”http://schemas.microsoft.com/expression/blend/2008″ Adding the mock data context to window/control resources <UserControl.Resources> <ViewModels:MockXViewModel x:Key=”DesignViewModel”/> </UserControl.Resources> Setting design-time data context <Grid d:DataContext=”{Binding Source={StaticResource DesignViewModel}}” … Works well enough.