dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.11k stars 1.17k forks source link

Intellisense Fails to Display Abstract Classes for RelativeSource Binding in WPF #8384

Open jamesnet214 opened 1 year ago

jamesnet214 commented 1 year ago

Description

In WPF applications, when using RelativeSource binding, Intellisense does not display abstract classes in the suggestion list while it does show concrete classes. This issue occurs in the Visual Studio 2022 Preview's XAML editing process. If an abstract class name is entered manually, the runtime binding functions correctly, indicating that the problem is limited to the Intellisense feature in the editor.

Reproduction Steps

  1. Open a WPF project in Visual Studio 2022 Preview.
  2. Navigate to a XAML file and start typing a binding.
  3. Observe that Intellisense does not suggest abstract classes when specifying the type for RelativeSource.
  4. Manually enter the name of an abstract class and run the application to verify that the binding works correctly at runtime.
<TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=james:JamesContent}, Path=DataContext}"/>
public abstract class  JamesContent
{

}

Expected behavior

Intellisense should list both abstract and concrete classes when specifying the type for RelativeSource in a WPF application's XAML file, aiding in the binding setup process.

Actual behavior

Intellisense omits abstract classes from the suggestion list when specifying the type for RelativeSource. There are no error messages or exception stack traces as the application executes as expected when the class name is manually entered.

Regression?

Intellisense omits abstract classes from the suggestion list when specifying the type for RelativeSource. There are no error messages or exception stack traces as the application executes as expected when the class name is manually entered.

Known Workarounds

The current workaround involves manually typing the full name of the abstract class when using RelativeSource binding.

Impact

The impact primarily affects developer experience, potentially causing confusion and slowing down the development process when using abstract classes in XAML bindings. It impacts developers who rely on Intellisense for coding assistance in WPF applications.

Configuration

  1. .NET Version: .NET 7.0
  2. OS and version: Windows 11
  3. Architecture: AnyCPU
  4. Impact specific to configuration unknown: The issue has been observed in the Visual Studio 2022 Preview XAML editor and has not been tested in other environments.

Other information

No additional information on the potential cause of the problem is available at this time. No relevant changes or related issues have been identified.

singhashish-wpf commented 1 year ago

@jamesnet214 Was this working earlier at some point in time? Which version of .NET 7 are you using?

jamesnet214 commented 1 year ago

Thank you for your response, @singhashish-wpf ! I have observed the same issue in the following environments:

Visual Studio 2022 Preview with .NET 7.0 Visual Studio 2022 Preview with .NET Framework 4.8.1

Here are the relevant screenshots for reference:

image

image

singhashish-wpf commented 1 year ago

@jamesnet214 Thanks for the details. Confirming once again, Did this ever work or not?

jamesnet214 commented 1 year ago

@singhashish-wpf I'm not sure about that specific detail, I'm sorry I couldn't be of more help.

singhashish-wpf commented 1 year ago

@jamesnet214 Thanks.

miloush commented 1 year ago

In my vague recollection I belive I also run into this and would think this never worked.