How do I avoid coupling XAML Views to start up code in a WPF MVVM application?
问题 I really like the flexibility of declaring my ViewModel on the DataContext of a View through XAML, but I am having a hard time figuring out how I can tie this ViewModel into the rest of the system. Ex. <Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:ViewModels"> <Window.DataContext> <local:MainViewModel /> </Window.DataContext> The problem here, is that my