Xamarin.Forms not recognizing SafeAreaInsets *at all* - xaml

Running Visual Studio for Mac with Forms version 3.1.0.637273.
The documentation says to do this in the code-behind:
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
...
On<Xamarin.Forms.PlatformConfiguration.iOS>().SetUseSafeArea(true);
Or this in the Xaml:
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
ios:Page.UseSafeArea="true"
I've done both, and both give the same error:
Error CS1061: 'IPlatformElementConfiguration<iOS, Page>' does not contain a definition for 'SetUseSafeArea'
I get no error from just doing this:
On<Xamarin.Forms.PlatformConfiguration.iOS>();
Which does me no good, but at least it proves that I'm accessing the PlatformConfiguration.iOS stuff without an error.
Why isn't my code recognizing anything having to do with SafeArea stuff at all?

Related

UWP XAML designer exception - Template10 stopped working suddenly

From one moment to another I am receiving the following error messages:
When starting the UWP app:
One of the content dialog constructor -> InitializeComponent() throws the following exception:
Windows.UI.Xaml.Markup.XamlParseException: 'The text associated with this error code could not be found.
Cannot deserialize XBF metadata property list as 'Behaviors' was not found in type 'Microsoft.Xaml.Interactivity.Interaction'. [Line: 0 Position: 0]'
http://prntscr.com/rb8bdj
And I can't open the XAML Designer:
http://prntscr.com/rb8boo
Template10 version: 1.1.12
Microsoft.Xaml.Behaviors.Uwp.Managed: 2.0.1
So the latest.
There was no any previous sign, this error come up from one moment to another today, everything was working smoothly before.
Can you please suggest anything how can I fix it or debug it?
Solution:
Finally figured out that anything went wrong with the project configuration, after deleting and readding the debug config solved the problem.

How can I create TeachingTip?

I am trying to add TeachingTip to Xaml file in a usual way:
<TeachingTip/>
But I get an error "The type 'TeachingTip' was not found".
I tried to add programmatically in cpp file (C++/CX):
TeachingTip^ tip = ref new TeachingTip();
The error is: "Identifier 'TeachingTip' is undefined".
All other controls work well.
The TechingTip control is part of the Windows UI Library, not Windows. As such it resides in namespace Microsoft.UI.Xaml.Controls (as opposed to Windows.UI.Xaml.Controls). To reference that control in XAML, you'll have to use the correct namespace. Getting started with the Windows UI Library has detailed instructions.
The following XAML fragment should work:
<Page x:Class="..."
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
...
>
<muxc:TeachingTip/>
...
</Page>
Likewise, when referencing the control in code, you'll have to specify the correct namespace.

Error adding WrapPanel

I created a new blank Windows 10 Universal app and tried to add a WrapPanel exactly as per the sample code in the link: WrapPanel XAML Control
I am getting the following error message on wrapPanel:WrapPanel
The name "WrapPanel" does not exist in the namespace "using:Microsoft.Toolkit.Uwp.UI.Controls.WrapPanel"
I have already added xmlns:wrapPanel="using:Microsoft.Toolkit.Uwp.UI.Controls.WrapPanel" as per sample code.
Full code and errors (please click image for better quality):
I have tried to Clean and Build/Rebuild but it doesn't help. I also made sure that I am targeting the latest Windows 10 version:
Please help!
Update: I tried using xmlns:wrapPanel="using:Microsoft.Toolkit.Uwp.UI.Controls"
as suggested but I still get this error. Again, I tried clean and build/rebuild and am getting the a similar error:
The documentation has a typo. The WrapPanel control is not in the Microsoft.Toolkit.Uwp.UI.Controls.WrapPanel namespace, but rather just in Microsoft.Toolkit.Uwp.UI.Controls, so use the following
xmlns:wrapPanel="using:Microsoft.Toolkit.Uwp.UI.Controls"
And it should work as expected. I will push an update for the docs.

Conditional XAML causes XBF generator error

I am trying to set the Icon property of MenuFlyoutItem on the UWP. As this is only available in contract version 4, I wanted to use conditional XAML statements in form of the IsApiContractPresent statement. Doing this, I came up with this code:
<MenuFlyout>
<MenuFlyoutItem Text="Open">
<contract4Present:MenuFlyoutItem.Icon>
<FontIcon Glyph=""/>
</contract4Present:MenuFlyoutItem.Icon>
</MenuFlyoutItem>
</MenuFlyout>
and added this line in the definition of my page:
xmlns:contract4Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,5)"
Sadly, Visual Studio is now not able to compile the project anymore, with this error message:
The XAML Binary Format (XBF) generator reported syntax error '0x09C4' : Property Not Found
Strangely, the same errors comes up, when I use the minimal example given in the documentation
<TextBlock contract5NotPresent:Text="Hello, World"
contract5Present:Text="Hello, Fall Creators Update"/>
How can I solve this error? Or is this even a bug of Visual Studio?
Apparently, this functions is only available for Minimum Build versions > 15063. Otherwise, you must use version adaptive code, and not XAML.

How do I get rid of these inexplicable design-time errors in an empty App.xaml?

I have an issue with App.xaml in a Silverlight 5 application project. Basically, I can remove everything (resources inside <Application.Resources>, such as styles and converters) from it, until I am left with only this:
<Application x:Class="SomeProject.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
</Application>
But Visual Studio 2013's Error List window will still list below three (ignorable) design-time errors:
The property "Resources" can only be set once. (App.xaml, Line 1, Column 1)
The "Key" attribute can only be used on an element that is contained in "IDictionary". (App.xaml, Line 1, Column 1)
The specified value cannot be assigned. The following type was expected: "ResourceDictionary". (App.xaml, Line 1, Column 1)
These are purely design-time errors; I can successfully compile and run the project. However, the errors don't make any sense, and they are annoying.
Does anyone know how to get rid of them?
Some things I've tried already:
Cleaning and rebuilding the whole solution.
Manually wiping the App.g.i.* files in the obj artifact directory.
Manually deleting the obj and bin directories.
I made sure that App.xaml is in the main Silverlight application project (not in some other class library); and there is no other project item of type "ApplicationDefinition".
Ah the joys of Silverlight development... While I don't have a completely competent technical answer to your question, I've found that restarting your machine can do magical things (I know, no true developer ever wants to hear the word "magical" in a fix) but one could assume there's a caching issue somewhere...
However the point is restarting can often clear up erroneous errors related to build time resources that you would normally expect a quick clean to fix.
Anyhow, glad you got a remedy. Cheers!