Offer
Offer

Reputation: 630

Project A can't reference a class in Project B

So in my solution I've got two projects. A and B.

In project A (My views project), I've added an assembly reference pointing to B(My ViewModels Project.)

So in code behind, finding a class in Project B works just fine.

using ViewModels.Appearance.Themes

The issue comes when I try to find it in XAML;

xmlns:local="clr-namespace:ViewModels.Appearance.Themes;assembly=ViewModels">

Intellisense seems to detect it as a valid location, but when I try and use the class in that namespace...

<Rectangle x:Key="WindowBackgroundContent" x:Shared="false" >
    <Rectangle.Fill>
        <ImageBrush local:BingImage.UseBingImage="True" Opacity=".3" Stretch="UniformToFill" />
    </Rectangle.Fill>
</Rectangle>

Intellisense tells me:

The attachable property 'UseBingImage' was not found in type 'BingImage'.

It seems the only way to make it work is if the BingImage.cs class has a namespace that's directly in Project B's root. But I'm not entirely comfortable braking the standard convention here.

Any suggestions on how to fix this?

Upvotes: 1

Views: 235

Answers (1)

Salah Akbari
Salah Akbari

Reputation: 39946

When you add a reference in your XAML, try to Rebuild your project once to recompile everything and to incorporate the referenced project and to make any new controls available. It is necessary when a file or a dependency has been changed, or even with no reason. But it will solve your issue.

Upvotes: 1

Related Questions