I'm working on a Xamarin Forms application that sets the BindingContext of my views in code. I was looking for ways to setup my XAML so that it would autocomplete properties from my ViewModels. I had been using some hack solution for this until I recently came across an article that described using the DesignInstance attribute. This works great except that Visual Studio reports the attribute as an error. In the Error List the description is:
MarkupExtension not found for d:DesignInstance
(there is no error code for this error)
If I go to the XAMl file and hover over the error the description there is:
The type 'd:DesignInstance' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built
The strange part is that despite these errors my application runs fine. My question is: Is there anyway to ignore or fix this error?
In the short term it's mostly just an annoyance but I'm worried about using this in the future with automated builds. I could see this causing the builds to fail when really they are fine.
MySuperAwesomeView.xaml
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:viewModels="clr-namespace:My.Namespace.ViewModels" mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:MySuperAwesomeViewModel}" x:Class="My.Namespace.Views.MySuperAwesomeView"> <ContentPage.Content> <!-- My content --> </ContentPage.Content> </ContentPage>
Answers
The issue is reported here , it seems that this problem has not been solved .
I tried to find a way to ignore the xaml error but no luck , the docs provides the way to Suppress XAML Designer errors but not XAML Language Service error .
You can raise issue on github for better help : https://github.com/xamarin/Xamarin.Forms/issues.
Refer to
https://docs.microsoft.com/en-us/visualstudio/xaml-tools/xaml-errors-warnings?view=vs-2019#suppress-xaml-designer-errors
Hey ColeX,
Thanks for the reply. I also tried to ignore the error but had no luck. Thanks for finding that original issue, in my searches I never came across it. I'll open an issue on GitHub.
Thanks again for the help!