Bug 20771 - RelativeToView does not work in a ListView ViewCell DataTemplate
Summary: RelativeToView does not work in a ListView ViewCell DataTemplate
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.0.6188
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-06-20 16:05 UTC by John Miller [MSFT]
Modified: 2015-08-05 10:20 UTC (History)
4 users (show)

Tags:
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:
VERIFIED FIXED

Description John Miller [MSFT] 2014-06-20 16:05:47 UTC
Created attachment 7139 [details]
TestCase

## Overview: 

    The attached project throws the following exception: System.InvalidOperationException: this element is not in a namescope
    This seems to be related to have the RelativeToView constraint in the ViewCell template in Menu.Xaml

## Steps to Reproduce: 

    1. Run the attached project on iOS.

## Actual Results: 

    System.InvalidOperationException: this element is not in a namescope

## Expected Results: 

    No exception, proper layout.

## Build Date & Platform: 

    XF 1.1.1.6206

## Additional Information: 

    RelativeToParent seems to work ok. 

## Full Stack Trace:

> Unhandled Exception:
System.InvalidOperationException: this element is not in a namescope
  at Xamarin.Forms.Element.Xamarin.Forms.INameScope.FindByName (System.String name) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.NameScopeExtensions.FindByName[View] (INameScope namescope, System.String name) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.ConstraintExpression.ProvideValue (IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.MarkupExtensionParser.Parse (System.String match, System.String& expression, IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.MarkupExpressionParser.ParseExpression (System.String& expression, IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.MarkupNode.ApplyTo (System.Object source, XmlName propertyName, INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.INodeExtension.ApplyProperties (IElementNode node, System.Object source, INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.ElementNode.ApplyProperties (INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.ElementNode.Create (IElement parent, INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.ListNode.ApplyTo (System.Object source, XmlName propertyName, INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.INodeExtension.ApplyProperties (IElementNode node, System.Object source, INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.ElementNode.ApplyProperties (INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.ElementNode.Create (IElement parent, INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.ElementNode.ApplyTo (System.Object source, XmlName propertyName, INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.INodeExtension.ApplyProperties (IElementNode node, System.Object source, INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.ElementNode.ApplyProperties (INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.ElementNode.Create (IElement parent, INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.ElementNode+<>c__DisplayClass6.<SetDataTemplate>b__5 () [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.DataTemplate.CreateContent () [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].CreateContent (Int32 index, System.Object item, Boolean insert) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].GetOrCreateContent (Int32 index, System.Object item) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].get_Item (Int32 index) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Platform.iOS.ListViewRenderer+ListViewDataSource.GetCell (MonoTouch.UIKit.UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath) [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSend (intptr,intptr)
  at MonoTouch.UIKit.UIWindow.MakeKeyAndVisible () [0x00010] in /Developer/MonoTouch/Source/monotouch/src/build/compat/UIKit/UIWindow.g.cs:215 
  at UxDemoAppXF.iOS.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary options) [0x00036] in /Users/John/Downloads/UxDemoAppXF-2/UxDemoAppXF/UxDemoAppXF.iOS/AppDelegate.cs:36 
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38 
  at UxDemoAppXF.iOS.Application.Main (System.String[] args) [0x00008] in /Users/John/Downloads/UxDemoAppXF-2/UxDemoAppXF/UxDemoAppXF.iOS/Main.cs:17 
2014-06-20 13:01:59.629 FormsTemplateiOS[3413:70b] Unhandled managed exception: this element is not in a namescope (System.InvalidOperationException)
  at Xamarin.Forms.Element.Xamarin.Forms.INameScope.FindByName (System.String name) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.NameScopeExtensions.FindByName[View] (INameScope namescope, System.String name) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.ConstraintExpression.ProvideValue (IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.MarkupExtensionParser.Parse (System.String match, System.String& expression, IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.MarkupExpressionParser.ParseExpression (System.String& expression, IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.MarkupNode.ApplyTo (System.Object source, XmlName propertyName, INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.INodeExtension.ApplyProperties (IElementNode node, System.Object source, INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.ElementNode.ApplyProperties (INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.ElementNode.Create (IElement parent, INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.ListNode.ApplyTo (System.Object source, XmlName propertyName, INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.INodeExtension.ApplyProperties (IElementNode node, System.Object source, INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.ElementNode.ApplyProperties (INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.ElementNode.Create (IElement parent, INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.ElementNode.ApplyTo (System.Object source, XmlName propertyName, INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.INodeExtension.ApplyProperties (IElementNode node, System.Object source, INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.ElementNode.ApplyProperties (INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.ElementNode.Create (IElement parent, INameScope namescope) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Xaml.ElementNode+<>c__DisplayClass6.<SetDataTemplate>b__5 () [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.DataTemplate.CreateContent () [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].CreateContent (Int32 index, System.Object item, Boolean insert) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].GetOrCreateContent (Int32 index, System.Object item) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].get_Item (Int32 index) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Platform.iOS.ListViewRenderer+ListViewDataSource.GetCell (MonoTouch.UIKit.UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath) [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSend (intptr,intptr)
  at MonoTouch.UIKit.UIWindow.MakeKeyAndVisible () [0x00010] in /Developer/MonoTouch/Source/monotouch/src/build/compat/UIKit/UIWindow.g.cs:215 
  at UxDemoAppXF.iOS.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary options) [0x00036] in /Users/John/Downloads/UxDemoAppXF-2/UxDemoAppXF/UxDemoAppXF.iOS/AppDelegate.cs:36 
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38 
  at UxDemoAppXF.iOS.Application.Main (System.String[] args) [0x00008] in /Users/John/Downloads/UxDemoAppXF-2/UxDemoAppXF/UxDemoAppXF.iOS/Main.cs:17
Comment 1 Parmendra Kumar 2014-08-19 08:07:12 UTC
I have checked this issue and able to reproduce this, To reproduce this issue I have followed the steps mentioned in bug description.
I have checked this issue on XF 1.2.2.6243, 1.0.6186 and get the same issue.

Screencast: http://www.screencast.com/t/WZBCt6AFN

Xamarin Forms Version: 1.2.2.6243 and 1.0.6186

Environment info:

=== Xamarin Studio ===

Version 5.2.1 (build 1)
Installation UUID: 1a096c6f-0678-402e-89b2-a2c10f7e80e4
Runtime:
	Mono 3.6.0 ((no/f540f8a)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 306000039

=== Xamarin.Android ===

Version: 4.14.0 (Business Edition)
Android SDK: /Users/360_macmini/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		3.2   (API level 13)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

=== Apple Developer Tools ===

Xcode 5.1 (5084)
Build 5B130a

=== Xamarin.iOS ===

Version: 7.2.6.28 (Business Edition)
Hash: 606f31a
Branch: 
Build date: 2014-08-01 15:27:48-0400

=== Xamarin.Mac ===

Version: 1.10.0.4 (Business Edition)

=== Build Information ===

Release ID: 502010001
Git revision: d06832ce9807d6be24aca225457e8b37c7669f6f
Build date: 2014-08-07 12:10:47-04
Xamarin addins: 1de032531be4cecf2f39dbee3b87aac78204058c

=== Operating System ===

Mac OS X 10.9.4
Comment 2 Jason Smith [MSFT] 2014-09-25 21:15:36 UTC
fixed for the 1.3 release
Comment 3 Parmendra Kumar 2015-08-05 10:20:36 UTC
I have checked this issue with X.F 1.4.4.6392 and its working fine.

Screencast: http://www.screencast.com/t/Zm5W5L6BYH

Hence closing this issue.