{"record":{"id":"ae6b9f9a254927bb","repo":"MaterialDesignInXAML/MaterialDesignInXamlToolkit","slug":"content","errorCode":null,"errorMessage":"content","messagePattern":"content","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/MaterialDesignThemes.Wpf/DialogHost.cs","lineNumber":174,"sourceCode":"    /// <param name=\"dialogIdentifier\"><see cref=\"Identifier\"/> of the instance where the dialog should be shown. Typically this will match an identifier set in XAML. <c>null</c> is allowed.</param>\n    /// <param name=\"openedEventHandler\">Allows access to opened event which would otherwise have been subscribed to on a instance.</param>\n    /// <param name=\"closingEventHandler\">Allows access to closing event which would otherwise have been subscribed to on a instance.</param>\n    /// <returns>Task result is the parameter used to close the dialog, typically what is passed to the <see cref=\"CloseDialogCommand\"/> command.</returns>\n    public static Task<object?> Show(object content, object? dialogIdentifier, DialogOpenedEventHandler? openedEventHandler, DialogClosingEventHandler? closingEventHandler)\n        => Show(content, dialogIdentifier, openedEventHandler, closingEventHandler, null);\n\n    /// <summary>\n    /// Shows a modal dialog. To use, a <see cref=\"DialogHost\"/> instance must be in a visual tree (typically this may be specified towards the root of a Window's XAML).\n    /// </summary>\n    /// <param name=\"content\">Content to show (can be a control or view model).</param>\n    /// <param name=\"dialogIdentifier\"><see cref=\"Identifier\"/> of the instance where the dialog should be shown. Typically this will match an identifier set in XAML. <c>null</c> is allowed.</param>\n    /// <param name=\"openedEventHandler\">Allows access to opened event which would otherwise have been subscribed to on a instance.</param>\n    /// <param name=\"closingEventHandler\">Allows access to closing event which would otherwise have been subscribed to on a instance.</param>\n    /// <param name=\"closedEventHandler\">Allows access to closed event which would otherwise have been subscribed to on a instance.</param>\n    /// <returns>Task result is the parameter used to close the dialog, typically what is passed to the <see cref=\"CloseDialogCommand\"/> command.</returns>\n    public static async Task<object?> Show(object content, object? dialogIdentifier, DialogOpenedEventHandler? openedEventHandler, DialogClosingEventHandler? closingEventHandler, DialogClosedEventHandler? closedEventHandler)\n    {\n        if (content is null) throw new ArgumentNullException(nameof(content));\n        return await GetInstance(dialogIdentifier).ShowInternal(content, openedEventHandler, closingEventHandler, closedEventHandler);\n    }\n\n    /// <summary>\n    ///  Close a modal dialog.\n    /// </summary>\n    /// <param name=\"dialogIdentifier\"> of the instance where the dialog should be closed. Typically this will match an identifier set in XAML. </param>\n    public static void Close(object? dialogIdentifier)\n        => Close(dialogIdentifier, null);\n\n    /// <summary>\n    ///  Close a modal dialog.\n    /// </summary>\n    /// <param name=\"dialogIdentifier\"> of the instance where the dialog should be closed. Typically this will match an identifier set in XAML. </param>\n    /// <param name=\"parameter\"> Value returned by DialogHost.ShowDialog(...) or passed to close handler if one is provided.</param>\n    public static void Close(object? dialogIdentifier, object? parameter)\n    {\n        DialogHost dialogHost = GetInstance(dialogIdentifier);","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/98edec3a0b96ef272c587b14bcd67ef5f928a7ed/src/MaterialDesignThemes.Wpf/DialogHost.cs#L156-L192","documentation":"`DialogHost.Show(...)` requires a non-null `content` argument (the control or view model to display). If null is passed it throws `ArgumentNullException(nameof(content))` before resolving the host instance. The message text is just the parameter name \"content\".","triggerScenarios":"Calling `await DialogHost.Show(null, identifier, ...)` — e.g. the content expression evaluated to null because the view model was not constructed or the XAML resource was missing.","commonSituations":"Passing a not-yet-initialized view model field; resolving content from a service/locator that returned null; forgetting to instantiate the dialog view model before showing.","solutions":["Pass a non-null content object (a `UserControl`, `FrameworkElement`, or view model) to `Show`.","Null-check the content before calling: `if (content is null) return;`.","Ensure any DI/resolver that supplies the content returns a real instance.","Construct the dialog view model eagerly when the host is created."],"exampleFix":"// before\nawait DialogHost.Show(_dialogViewModel, \"RootDialog\"); // _dialogViewModel is null -> throws\n\n// after\n_dialogViewModel ??= new DialogViewModel();\nawait DialogHost.Show(_dialogViewModel, \"RootDialog\");","handlingStrategy":"validation","validationCode":"object content = BuildDialogContent();\nif (content is null) return; // or log\nawait DialogHost.Show(content, DialogIds.Root);","typeGuard":"static bool HasContent(object? content) => content is not null;","tryCatchPattern":null,"preventionTips":["Construct dialog content/view models before calling Show.","Null-check content at the call site.","Ensure DI/locators that supply content return real instances."],"tags":["wpf","dialog","argument-null","material-design"],"backgroundTag":null,"analyzedSha":"98edec3a0b96ef272c587b14bcd67ef5f928a7ed","analyzedAt":"2026-08-13T14:31:19.111Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}