{"record":{"id":"bd00a04604ef88a2","repo":"cefsharp/CefSharp","slug":"please-provide-a-valid-command-parameter-for-bindi","errorCode":null,"errorMessage":"Please provide a valid command parameter for binding","messagePattern":"Please provide a valid command parameter for binding","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"CefSharp.Wpf.Example/MainWindow.xaml.cs","lineNumber":241,"sourceCode":"                    {\n                        MessageBox.Show(\"Pdf was saved to \" + dialog.FileName);\n                    }\n                    else\n                    {\n                        MessageBox.Show(\"Unable to save Pdf, check you have write permissions to \" + dialog.FileName);\n                    }\n\n                }\n            }\n        }\n\n        private void OpenTabCommandBinding(object sender, ExecutedRoutedEventArgs e)\n        {\n            var url = e.Parameter.ToString();\n\n            if (string.IsNullOrEmpty(url))\n            {\n                throw new Exception(\"Please provide a valid command parameter for binding\");\n            }\n\n            CreateNewTab(url, true);\n\n            TabControl.SelectedIndex = TabControl.Items.Count - 1;\n        }\n\n        private void Exit(object sender, ExecutedRoutedEventArgs e)\n        {\n            Close();\n        }\n\n        private void CloseTab(BrowserTabViewModel browserViewModel)\n        {\n            if (BrowserTabs.Remove(browserViewModel))\n            {\n                browserViewModel.WebBrowser?.Dispose();\n            }","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/cefsharp/CefSharp/blob/16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec/CefSharp.Wpf.Example/MainWindow.xaml.cs#L223-L259","documentation":"Thrown by the WPF example MainWindow.OpenTabCommandBinding when the routed command parameter (e.Parameter) is null or empty after ToString(). The handler opens a new browser tab at the given URL, so a missing/blank parameter has no target to navigate to and is rejected. It is example-code-level validation, not framework logic.","triggerScenarios":"Binding a Button/MenuItem Command to OpenTabCommand without supplying a CommandParameter, or with an empty/null parameter; e.Parameter being null so ToString() yields empty.","commonSituations":"XAML command binding missing the CommandParameter attribute; parameter bound to a property that is null at click time; copy-paste of a command binding without updating the URL argument.","solutions":["Supply a non-empty CommandParameter in XAML: `CommandParameter=\"https://example.com\"`.","Bind CommandParameter to a non-null view-model property (the URL).","In the handler, replace the throw with a guard that returns/ignores a null parameter instead of crashing.","Validate/debug that the bound property is populated before the command can execute."],"exampleFix":"// before (XAML)\n<Button Content=\"Open\" Command=\"{Binding OpenTabCommand}\" /> <!-- no parameter -->\n\n// after\n<Button Content=\"Open\" Command=\"{Binding OpenTabCommand}\" CommandParameter=\"https://github.com\" />","handlingStrategy":"validation","validationCode":"var url = e.Parameter?.ToString();\nif (!string.IsNullOrEmpty(url))\n{\n    CreateNewTab(url, true);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always supply a non-empty CommandParameter in XAML for the OpenTab command.","Bind CommandParameter to a non-null view-model URL property.","Replace the example throw with a guard that ignores a missing parameter."],"tags":["cefwsharp","wpf","example","commands","validation"],"backgroundTag":null,"analyzedSha":"16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec","analyzedAt":"2026-08-13T19:57:05.828Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}