Where should custom Window initialization code be placed?
The best place for Window initialization code is in a handler for the form's Loaded event. The constructor is no longer the best place (as it was in Windows Forms). This is because exceptions encountered in the Window's constructor are thrown when the XAML parser is parsing the Window and the exception is wrapped in a XamlParseException object with the original exception stored in the InnerException property.
© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 03/30/11
Comment or report problem with topic
