2
votes

I have a ResourceDictionary in a file separate from the UserControl, named MyControl.xaml, I'm making. At the top of my that page, I put

<UserControl.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/Resources;component/AppDictionary.xaml"/>
        </ResourceDictionary.MergedDictionaries>

        <Style x:Key="MyTextBoxStyle" BasedOn="{StaticResource ThisTextBoxStyle}" TargetType="TextBox">
            <Setter Property="Margin" Value="10,0,10,0"/>
        </Style>

        <Style x:Key="MyLabelStyle" BasedOn="{StaticResource ThisLabelStyle}" TargetType="TextBlock">
            <Setter Property="Margin" Value="10,20,0,0"/>
        </Style>
    </ResourceDictionary>
</UserControl.Resources>

The first StaticResource is seen just fine by VS, no warnings/errors. However, with the second one it says, "The resource 'ThisLabelStyle' could not be resolved." But then it compiles and runs just fine. There is nothing even in either style. Is it just VS being weird?

Using VS 2015. I even use other StaticResources later in the file, some have no problem, others have the same error, no connection between them as far as I can see.

1
Error should disappear with DynamicResource.aybe
Tried it, error still stays, still compiles and runs.user6732861
Welcome to the wonderful world of Visual Studio. The IDE is buggy there is really nothing you can do to prevent this from happening.MakanWG
Agreed with @MakanWG the XAML editor is terribly unreliable, particularly as things get more complex with resource dictionaries and whatnot. You can ignore the Intellisense errors if it compiles and runs properly.Peter Moore
Alright, that's what I picked up from a couple other SO posts, but was hopeful that my problem actually had an answer or something. Thanks for confirminguser6732861

1 Answers

0
votes

Try deleting the .vs folder that sits at the same level as your solution file. That did the trick for me. it appears that corrupted intellisense information somehow was cached in there.