While porting a WPF project from .NET Framework to .NET Core I ran into a problem with the XAML-Designer in VS2019 v16.3.10
. It keeps throwing XDG0062
errors when I try to use EventSetter
in styles. The code compiles and runs fine, but the errors cause the concerned elements in the designer to be replaced by a red circle with an X, making designing a UI rather hard. The same XAML works fine in a .NET framework 4.7.2.
project.
To track down the problem I made a VS minimal project (WPF .NET Core) from scratch and the problem occurs here as well (see errors and code below). It seems to be caused by the use of EventSetter
in styles - unfortunately I have no clue why. Google yielded one mention of the problem without a solution, Stack Overflow has one topic on this error code, however, the solution suggested there (deleting VS cache) didn´t help. Deleting the EventSetter
line removes both error messages.
Does anyone have a suggestion to solve this?
Full error messages:
Line 9: XDG0062 Non-NULL value required for "EventSetter.Handler"
Line 12: XDG0062 Value cannot be null. (Parameter 'typeDescriptorContext')
XAML:
<Window x:Class="XDG0062_test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:XDG0062_test"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.Resources>
<Style TargetType="TextBox">
<Setter Property="Height" Value="30"></Setter>
<Setter Property="Width" Value="130"></Setter>
<EventSetter Event="GotFocus" Handler="TextBox_GotFocus"/>
</Style>
</Window.Resources>
<Grid>
<TextBox HorizontalAlignment="Left" Margin="70,100,0,0"
Text="TextBox" TextWrapping="Wrap" VerticalAlignment="Top"/>
</Grid>
</Window>
C#:
using System.Windows;
namespace XDG0062_test
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void TextBox_GotFocus(object sender, RoutedEventArgs e)
{
MessageBox.Show("Beep");
}
}
}
I solved this by deleting the folder .vs/$(SolutionName)/DesignTimeBuild
, so I can keep VS configuration/explorer/tabs, which are lost when deleting the whole .vs
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With