0

Photos of the code: The error: ContentPage

Cs file

Xaml file

another css file

I am new to Visual Studio for Mac(building my first project here). So far everything was going just fine, but when I tried to utilise <StackPanel> </StackPanel> - I ran into a problem. The is underlined with red, and I received an error that < The type 'StackPanel' was not found.Verify that you are not missing an assembly reference and that all referenced assemblies have been built.>

Additional information: File's form: File.xaml

Could you please indicate which assembly or package should I install to eliminate the error? And also specify the way to execute your instructions.

Jace
  • 5
  • 2

1 Answers1

0

StackPanel could not be found (missing assembly reference)

Not entirely sure but you can try to add the PresentationFramework reference in your project references

Open project references

Add PresentationFramework

If that doesn't help read this post and it's comment: The type was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built

Try adding the reference in your code with something like this

<Window x:Class="YourClassName"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="StackPanel" Height="160" Width="300">

Some links:

https://www.infragistics.com/help/wpf/adding-assembly-to-a-visual-studio-project

https://wpf-tutorial.com/panels/stackpanel/

https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/xaml-namespaces-and-namespace-mapping-for-wpf-xaml?view=netframeworkdesktop-4.8

Hope these can help explain a bit more

Raptor22
  • 171
  • 1
  • 10
  • Hey! I successfully downloaded the file from the NuGet and added it to my References. It's still underlined. Is there anything I missed, maybe I should somehow initialise it in code? What I'm implying is, are there any other procedures that I should go through in order to ensure the functionality of the given assembly? – Jace Jul 26 '22 at 21:42
  • Moreover, I checked the last link as well, and I don't think that the version of the Visual Studio is responsible for this glitch. I have the latest existing version of the program. – Jace Jul 26 '22 at 21:44
  • I've searched around a bit and found a few links. My theory right now is that your code doesn't reference the namespace yet. Try adding `xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"` to your top level tag. I've added a few more links in my answer. If that still doesn't help it would be helpful if you provided some code and your project type. – Raptor22 Jul 27 '22 at 05:42
  • I appreciate your help, as requested I added to my previous post some screenshots of the code, along with all the included libraries and assemblies. When I ran the program the stackpanel error vanished, whilst another has appeared(something to do with the ContentPage(please see the attached photos in the post)). I was hoping you could help me resolve that issue as well, maybe there is another assembly that I am missing? Almost forgot to mention, my project type is a mobile app(both for android and ios). – Jace Jul 27 '22 at 20:12
  • Thank you for those additions. I saw two things in your screenshots. First, the issue with the content page, I don't know what error exactly appears but I suspect is has to do with the `Width` and `Height` tags you added to the ``. According to https://docs.microsoft.com/en-us/dotnet/api/xamarin.forms.contentpage?view=xamarin-forms, these Tags in ContentPage are read-only, so you can't set them in code. The other thing I saw is a missing semicolon on line 12 of your App.cs. Could you also provide the exact error messages as you did with the StackPanel if it still doesn't work? – Raptor22 Jul 28 '22 at 06:16
  • Right, it still gives out the same error, even after I got rid of the Height and Width. I attached the screenshot of the error in the main post.I hope it will help resolve the problem. – Jace Jul 28 '22 at 11:35
  • Seems to be something more complicated, which I am not experienced enough to help you with. Sorry to disappoint. The issue could be solved by simply running Clean and Rebuild so I would try doing that if you haven't already. This might also be a helpful link: https://github.com/xamarin/Xamarin.Forms/issues/11101#issuecomment-678329339 – Raptor22 Jul 28 '22 at 11:52
  • Thanks, anyway. You did help me resolve the other error. I'd already run the Clean and Rebuild, didn't fix the error. I'll browse through the internet a bit more, I might spot sth useful. – Jace Jul 28 '22 at 12:21