Problem description:
I have a resource key defined as below:
namespace Wpf1
{
public abstract class ResourceExtension : TypeExtension
{
public ResourceExtension()
{
this.Type = this.GetType();
}
public override object ProvideValue(IServiceProvider serviceProvider)
{
return this.Type;
}
}
public class NormalBackground : ResourceExtension
{
}
}
And I use it in XAML as below:
<Window
x:Class="Wpf1.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:Wpf1"
mc:Ignorable="d"
Title="MainWindow"
Height="450"
Width="800">
<Window.Resources>
<SolidColorBrush
x:Key="{local:NormalBackground}"
Color="Green" />
</Window.Resources>
<Grid>
<Border
Background="{StaticResource {local:NormalBackground}}" />
</Grid>
</Window>
Actual behavior:
When I type the x:Key="{local:NormalBackground}", it has no intellisense, however when I type the Background="{StaticResource {local:NormalBackground}}", the intellisense works fine.
Expected behavior:
The x:Key also has intellisense.
Minimal repro:
Wpf1.zip
@chenyj796 - The value of x:key is an arbitrary string and this is an expected behavior.
@gomathip02 I don't think thats a string, thats a markup extension isn't it? You should be able to expect intellisense for a markup extension.
@gomathip02 that is not even true, x:Key can be any arbitrary object and often it is not a string at all.
A typical example would be using type as a key for a style to apply it to all instances of the type: <Style x:Key="{x:Type TextBlock}">. You should definitely get an autocompletion list of available types in this case and I would think that used to be the case.
Sorry about that everyone, mistakes were made (don't blame @gomathip02).
Re-opening this. I am not sure if this will end up here in the long run. This seems like a VS issue since (I believe) that we are providing all the necessary information for intellisense to be enabled for x:Key.
Anyway, kicking this to triage again so we can better understand where the issue lies. And thanks for the corrections.
FYI: @SamBent @vatsan-madhavan
@chabiss - This seems to be VS issue. Can you pls take a look?
Most helpful comment
Sorry about that everyone, mistakes were made (don't blame @gomathip02).
Re-opening this. I am not sure if this will end up here in the long run. This seems like a VS issue since (I believe) that we are providing all the necessary information for intellisense to be enabled for x:Key.
Anyway, kicking this to triage again so we can better understand where the issue lies. And thanks for the corrections.
FYI: @SamBent @vatsan-madhavan