Bug 42479 - Using the Margin property in XAML page throws the runtime exception
Summary: Using the Margin property in XAML page throws the runtime exception
Status: RESOLVED INVALID
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.0
Hardware: PC Mac OS
: Normal major
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-07-12 06:25 UTC by Prashant Cholachagudda
Modified: 2017-01-18 09:25 UTC (History)
6 users (show)

Tags: ac
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Prashant Cholachagudda 2016-07-12 06:25:28 UTC
Xamarin.Forms (version 2.3.0.107) throws an `Xamarin.Forms.Xaml.XamlParseException` on app startup, when use the `Margin` property in the XAML. 

The exception occurs on both Android and iOS

# Example:

<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
		xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
		xmlns:local="clr-namespace:XamlMargin" x:Class="XamlMargin.XamlMarginPage"
		Margin="0,20,15,5">

	<StackLayout VerticalOptions="Center" Margin="0,20,15,5" >
		<Entry Placeholder="USERNAME" HorizontalTextAlignment="Center" Margin="5"/>
		<Entry Placeholder="PASSWORD" IsPassword="true" HorizontalTextAlignment="Center" Margin="5"/>
		<Button Text="Login" Margin="20" />
	</StackLayout>
</ContentPage>

# Exception from iOS:

Xamarin.Forms.Xaml.XamlParseException: Position 5:3. No Property of name Margin found
  at Xamarin.Forms.Xaml.ApplyPropertiesVisitor.SetPropertyValue (System.Object xamlelement, XmlName propertyName, System.Object value, System.Object rootElement, INode node, Xamarin.Forms.Xaml.HydratationContext context, IXmlLineInfo lineInfo) [0x004a9] in <filename unknown>:0
  at Xamarin.Forms.Xaml.ApplyPropertiesVisitor.Visit (Xamarin.Forms.Xaml.ValueNode node, INode parentNode) [0x000d8] in <filename unknown>:0
  at Xamarin.Forms.Xaml.ValueNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Xaml.RootNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00054] in <filename unknown>:0
  at Xamarin.Forms.Xaml.XamlLoader.Visit (Xamarin.Forms.Xaml.RootNode rootnode, Xamarin.Forms.Xaml.HydratationContext visitorContext) [0x00076] in <filename unknown>:0
  at Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.String xaml) [0x00052] in <filename unknown>:0
  at Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.Type callingType) [0x0002e] in <filename unknown>:0
  at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[TXaml] (Xamarin.Forms.Xaml.TXaml view, System.Type callingType) [0x00000] in <filename unknown>:0
  at XamlMargin.XamlMarginPage.InitializeComponent () [0x0000c] in /Users/prashantvc/Projects/XamlMargin/XamlMargin/obj/Debug/XamlMargin.XamlMarginPage.xaml.g.cs:21
  at XamlMargin.XamlMarginPage..ctor () [0x00008] in /Users/prashantvc/Projects/XamlMargin/XamlMargin/XamlMarginPage.xaml.cs:9
  at XamlMargin.App..ctor () [0x0000e] in /Users/prashantvc/Projects/XamlMargin/XamlMargin/App.xaml.cs:11
  at XamlMargin.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x00007] in /Users/prashantvc/Projects/XamlMargin/iOS/AppDelegate.cs:17
  at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/src/UIKit/UIApplication.cs:79
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/src/UIKit/UIApplication.cs:63
  at XamlMargin.iOS.Application.Main (System.String[] args) [0x00008] in /Users/prashantvc/Projects/XamlMargin/iOS/Main.cs:17
Comment 1 Stephane Delcroix 2017-01-18 09:25:18 UTC
There's no `Margin` property defined on `ContentPage`. throwing the exception is the expected behavior...