Search code examples
wpfstylesheetstyles

How do I get intellisense for me?


I'm a web designer learning WPF. One of the things I need to learn are styles.

When I was using CSS all I had to do is go to a site like w3 and see what styles were supported for various tags. The examples from WPF seem to rely on intellisense instead of a fixed list of styles.

Other people seem to be able to add <Setter Property="BackgroundHover" Value="Red"> without an issue. When they do it BackgroundHover is supplied by intellisense. They don't have to search for it. This is not the case on my machine. Since I can not find a published list of properties to set for the style I'm left up the proverbial creek.

How do I either fix intellisense for styles or find out what styles are supported for a given third party UserControl?


Solution

  • For intellisense to work for properties set that way, it needs to know what type that the setter is being applied to. So in the style, set the TargetType to the type that you will be applying the style to and intellisense can offer suggestions to the values.

    <Style TargetType="MyType">
        <Setter Property="MyProperty" Value="MyValue" />
    </Style>
    

    You'll also want to make sure you have the right versions of everything on your machine. The same libraries, same versions of Visual Studio, the same code, etc. Also there should not be any other errors in the XAML file. Intellisense should be working then.