Skip to content

Simple NET WPF showing the XAML Designer error with CefSharp browser

Notifications You must be signed in to change notification settings

DrCQ/Example_NET_WPF_Plain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NET WPF Application (XAML Designer Error)

This is a simple NET7 - WPF application to show the XAML Designer error while using the CefSharp browser. Following Nuget packages are used:

  • CommunityToolkit.Mvvm (V8.2.0)
  • Microsoft.Extensions.DependencyInjection (V7.0.0)
  • CefSharp.Wpf.NETCore (V114.2.100)

Architecture

The XAML MainWindow is hosting three Border elements in the Grid for: Title, Chromium WebBrowser and 'Close' Button. The 'Close' Button is bounded to the CloseCommand defined in the MainWindowViewModel class and using the MainWindow refernce as CommandParameter.

The MainWindowViewModel class is using the CommunityToolkit.Mvvm to create the 'Close' command as RelayCommand(Of Window).

The ViewModelLocator class is using the IServiveProvider interface to allow the View classes (like MainWindow) to access the related ViewModel classes (like MainWindowViewModel).

Error Description

This small application runs as expected without any runtime errors (in Debug and Release mode), but the XAML Designer is raising an exception:

Parameter "parameter" (object) cannot be of type Microsoft.VisualStudio.XSurface.Wpf.Window, as the command type requires an argument of type System.Windows.Window. (Parameter 'parameter')

StackTrace:

at CommunityToolkit.Mvvm.Input.RelayCommand1.ThrowArgumentExceptionForInvalidCommandArgument(Object parameter) at CommunityToolkit.Mvvm.Input.RelayCommand1.CanExecute(Object parameter) at System.Windows.Controls.Primitives.ButtonBase.UpdateCanExecute() at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue) at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange) at System.Windows.Data.BindingExpression.Activate(Object item) at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt) at System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance) at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance) at MS.Internal.Data.DataBindEngine.Run(Object arg) at MS.Internal.Data.DataBindEngine.OnLayoutUpdated(Object sender, EventArgs e) at System.Windows.ContextLayoutManager.fireLayoutUpdateEvent() at System.Windows.ContextLayoutManager.UpdateLayout() at Microsoft.VisualStudio.DesignTools.WpfTap.WpfVisualTreeService.VisualTree.DispatcherVisualTreeContext.UpdateLayout() at Microsoft.VisualStudio.XSurface.Wpf.DesignerTapInstanceManager.AfterProcessActions(TapInstanceBuilderContext context)

The VS Tooltip over the ChromiumWebBrowser shows: Cannot load a reference assembly for execution

Unexpected Behavior

Commenting the CommandParameter of the 'Close' button is not raising the XAML Designer exception, but of cource the execution is not working (app is not closing).

CommandParameter="{Binding Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type local:MainWindow}}}"

About

Simple NET WPF showing the XAML Designer error with CefSharp browser

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published