-1

Screen shot of the issue I'm running into after going to .NET 5 (C# 9)

I'm trying to figure out how they want us to implement this simple code now.

It says its an error but it still builds the project. Although, this does prevents designer from building the view from xaml, so unable to edit the xaml properly, also prevents the functionality, in this case trying to drag a window with mouse_down event.

XAML:

<Window x:Class="WPFProject.Window1"
        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:WPFProject"
        mc:Ignorable="d"
        Title="Window1" Height="450" Width="800">
    
    <Border MouseDown="CodeBehind_DragFunction">
        <TextBlock Text="Hello World" Foreground="Black"/>
    </Border>
</Window>
C# Code-behind
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }

        void CodeBehind_DragFunction(object sender_, MouseButtonEventArgs e_)
        {
            DragMove();
        }
    }

This worked in previous versions..

Caio T
  • 1
  • 1
  • Does this issue prevent the build or is this only a designer warning? – Pharaz Fadaei Jul 19 '21 at 23:50
  • First, please always post error messages as text. Second, please always include a [mcve] that reliably reproduces the problem. Note that _all_ objects in C# inherit `System.Object`, so the error message seems spurious to me. But without a [mcve], there's no way to understand how you triggered the error. – Peter Duniho Jul 19 '21 at 23:52
  • Try `MouseLeftButtonDown`? – Mr. Squirrel.Downy Jul 20 '21 at 00:59
  • This might be a designer bug. Follow the steps explained [here](https://stackoverflow.com/questions/41730378/the-event-foo-is-not-a-routedevent/41742877#41742877) to see if it helps. – Pharaz Fadaei Jul 20 '21 at 01:01
  • Not reproducible given the code you posted. I suspect you've got a spurious character that accidentally got inserted somewhere, either invisible or looking like the right character but a different character point. In any case, it's clear you didn't post code that is exactly like whatever the code you're actually having trouble with is. – Peter Duniho Jul 20 '21 at 01:01
  • @PharazFadaei That did it! Thank you! Now I don't know how to mark this answer solved.... – Caio T Jul 20 '21 at 01:14

1 Answers1

0

Suggested answer posted by @Pharaz Fadaei It was an IDE bug that was fixed by following these steps outlined in this post: The event 'foo' is not a RoutedEvent

Caio T
  • 1
  • 1