private static void OnIsDialogChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { bool isDialog = (bool)args.NewValue; Window w = obj as Window; // TODO During design this crashes because either the window instance // doesn't exist, or something funky either way, this may need to be looked at if (w == null) { return; } if (isDialog && !w.IsLoaded) { w.Loaded += new RoutedEventHandler(WindowUtil.Window_IsDialog_Loaded); } if (!w.IsLoaded) { return; } WindowUtil.SetIsDialog(w, isDialog); }