Select to view content in your preferred language

FeatureDataGrid Sample Error...

1053
5
03-13-2011 11:10 PM
GirishS1
Emerging Contributor
Hi,
I am trying to use FeatureDataGrid sample from the Interactive Samples...
I am getting Error : "Sys.InvalidOperationException: ManagedRuntimeError erro #4004 in control 'Xaml1'. System.Windows.Markup.XamlParseException:.........."
I am using VS2008 with Silverlight 3.0V and ArcGIS API 1.2V..( i have to work on this environment only..)
Can any one help me out in this issue..
0 Kudos
5 Replies
JenniferNery
Esri Regular Contributor
Are you using this sample? http://help.arcgis.com/en/webapi/silverlight/1.2/samples/start.htm#FeatureDataGrid.

If you had been using the samples from v2.1: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ToolkitFeatureDataGrid. The XAML Parse Exception could be caused by the Binding statements that are not yet supported in VS 2008. If you were using the latter sample, please use the first link instead.
0 Kudos
GirishS1
Emerging Contributor
Hi Jennifer
Thanks for your reply.. I am using the first link...  http://help.arcgis.com/en/webapi/sil...eatureDataGrid.

Even though i m getting the same error.. can you please share me how to bind the layers to FeatureDataGrid in code behind...

Are you using this sample? http://help.arcgis.com/en/webapi/silverlight/1.2/samples/start.htm#FeatureDataGrid.

If you had been using the samples from v2.1: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ToolkitFeatureDataGrid. The XAML Parse Exception could be caused by the Binding statements that are not yet supported in VS 2008. If you were using the latter sample, please use the first link instead.
0 Kudos
JenniferNery
Esri Regular Contributor
You should be using the 1.2 sample (1st link from post#2).

One of the key differences in the two samples:
in 1.2 (VS 2008)
<esriToolkit:FeatureDataGrid Grid.Row="2" x:Name="MyDataGrid"
Map="{Binding ElementName=MyMap}"
GraphicsLayer="{Binding ElementName=MyMap, Path=Layers.[1]}" />
in 2.0 (VS 2010)
<esri:FeatureDataGrid Grid.Row="2" x:Name="MyDataGrid"
Map="{Binding ElementName=MyMap}"
GraphicsLayer="{Binding ElementName=MyMap, Path=Layers.[California]}" />

The equivalent code-behind binding is:
Binding mapBinding = new Binding();
mapBinding.Source = MyMap;
MyDataGrid.SetBinding(FeatureDataGrid.MapProperty, mapBinding);

Binding graphicsLayerBinding = new Binding("Layers.[1]");
graphicsLayerBinding.Source = MyMap;
MyDataGrid.SetBinding(FeatureDataGrid.GraphicsLayerProperty, graphicsLayerBinding);


If you don't require binding, you can simply set these properties:
MyDataGrid.Map = MyMap;
MyDataGrid.GraphicsLayer = MyMap.Layers[1] as GraphicsLayer;
0 Kudos
GirishS1
Emerging Contributor
Hi Jennifer

I tried to bind the featuredatagrid from code behind on page load.. still the same error persists.. i dont no what i am doing wrong can you please check this code and let me know...
Here is my Code behind code:

public partial class Page : UserControl 

public Page() 

InitializeComponent(); 

MyDataGrid.Visibility = Visibility.Visible; 
Binding mapBinding = new Binding(); 
mapBinding.Source = MyMap; 
MyDataGrid.SetBinding(FeatureDataGrid.MapProperty, mapBinding); 

Binding graphicsLayerBinding = new Binding("Layers.[1]"); 
graphicsLayerBinding.Source = MyMap; 
MyDataGrid.SetBinding(FeatureDataGrid.GraphicsLayerProperty, graphicsLayerBinding); 
MyDataGrid.UpdateLayout(); 

private void FeatureLayer_MouseLeftButtonDown(object sender, Graphic graphic, MouseButtonEventArgs args) 

graphic.Selected = !graphic.Selected; 
if (graphic.Selected) 
MyDataGrid.ScrollIntoView(graphic, null); 



Here is my Xaml code :
<UserControl x:Class="SilverlightApplication2.Page" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
xmlns:basics="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"  
xmlns:sys="clr-namespace:System;assembly=mscorlib" 
xmlns:esri="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client" 
xmlns:esriSymbols="clr-namespace:ESRI.ArcGIS.Client.Symbols;assembly=ESRI.ArcGIS.Client" 
xmlns:esriToolkit="clr-namespace:ESRI.ArcGIS.Client.Toolkit;assembly=ESRI.ArcGIS.Client.Toolkit" > 
<Grid x:Name="LayoutRoot" Background="White"> 
<Grid.Resources> 
<esriSymbols:SimpleFillSymbol x:Name="SelectSymbol"> 
<esriSymbols:SimpleFillSymbol.ControlTemplate> 
<ControlTemplate> 
<Path x:Name="Element" Fill="#330000FF" Stroke="Black" StrokeThickness="1" 
Cursor="Hand"> 
<VisualStateManager.VisualStateGroups> 
<VisualStateGroup x:Name="SelectionStates"> 
<VisualState x:Name="Unselected" /> 
<VisualState x:Name="Selected"> 
<Storyboard> 
<ColorAnimation Storyboard.TargetName="Element" 
Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"  
To="#99FFFF00" Duration="0:0:.25" /> 
<ColorAnimation Storyboard.TargetName="Element" 
Storyboard.TargetProperty="(Path.Stroke).(SolidColorBrush.Color)"  
To="#9900FFFF" Duration="0:0:.25" /> 
<DoubleAnimation Storyboard.TargetName="Element"  
Storyboard.TargetProperty="StrokeThickness" 
To="3" Duration="00:00:.25" /> 
</Storyboard> 
</VisualState> 
</VisualStateGroup> 
</VisualStateManager.VisualStateGroups> 
</Path> 
</ControlTemplate> 
</esriSymbols:SimpleFillSymbol.ControlTemplate> 
</esriSymbols:SimpleFillSymbol> 
</Grid.Resources> 

<Grid.RowDefinitions> 
<RowDefinition Height="*" /> 
<RowDefinition Height="5" /> 
<RowDefinition Height="150" /> 
</Grid.RowDefinitions> 

<esri:Map x:Name="MyMap" Background="White" Extent="-125,32,-114,42"> 
<esri:Map.Layers> 
<esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer" 
Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"/> 
<esri:FeatureLayer FeatureSymbol="{StaticResource SelectSymbol}" 
Url="http://serverapps.esri.com/ArcGIS/rest/services/California/MapServer/8
MouseLeftButtonDown="FeatureLayer_MouseLeftButtonDown"> 
<esri:FeatureLayer.OutFields> 
<sys:String>*</sys:String> 
</esri:FeatureLayer.OutFields> 
</esri:FeatureLayer> 
</esri:Map.Layers> 
</esri:Map> 
<basics:GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" /> 
<esriToolkit:FeatureDataGrid Grid.Row="2" x:Name="MyDataGrid" Visibility="Collapsed"/> 
</Grid> 
</UserControl> 


I am not getting where i am doing the mistake...

This is the error message i am getting:
System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException: AG_E_PARSER_BAD_TYPE [Line: 89 Position: 164] 
at MS.Internal.XcpImports.CheckHResult(UInt32 hr) 
at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize) 
at System.Windows.FrameworkElement.MeasureOverride(Size availableSize) 
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight) [Line: 0 Position: 0] 
at MS.Internal.XcpImports.CheckHResult(UInt32 hr) 
at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize) 
at System.Windows.FrameworkElement.MeasureOverride(Size availableSize) 
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight) [Line: 0 Position: 0] 
at MS.Internal.XcpImports.CheckHResult(UInt32 hr) 
at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize) 
at System.Windows.FrameworkElement.MeasureOverride(Size availableSize) 
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight) [Line: 0 Position: 0] 
at MS.Internal.XcpImports.CheckHResult(UInt32 hr) 
at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize) 
at System.Windows.FrameworkElement.MeasureOverride(Size availableSize) 
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight) [Line: 0 Position: 0] 
at MS.Internal.XcpImports.CheckHResult(UInt32 hr) 
at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize) 
at System.Windows.FrameworkElement.MeasureOverride(Size availableSize) 
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight) [Line: 0 Position: 0] 



You should be using the 1.2 sample (1st link from post#2). 

One of the key differences in the two samples: 
in 1.2 (VS 2008) 
<esriToolkit:FeatureDataGrid Grid.Row="2" x:Name="MyDataGrid" 
Map="{Binding ElementName=MyMap}" 
GraphicsLayer="{Binding ElementName=MyMap, Path=  Layers.[1]}" /> 
in 2.0 (VS 2010) 
<esri:FeatureDataGrid Grid.Row="2" x:Name="MyDataGrid" 
Map="{Binding ElementName=MyMap}" 
GraphicsLayer="{Binding ElementName=MyMap, Path=  Layers.[California]}" /> 

The equivalent code-behind binding is: 
Binding mapBinding = new Binding();
mapBinding.Source = MyMap;
MyDataGrid.SetBinding(FeatureDataGrid.MapProperty, mapBinding);

Binding graphicsLayerBinding = new Binding("Layers.[1]");
graphicsLayerBinding.Source = MyMap;
MyDataGrid.SetBinding(FeatureDataGrid.GraphicsLayerProperty, graphicsLayerBinding);


If you don't require binding, you can simply set these properties: 
MyDataGrid.Map = MyMap;
MyDataGrid.GraphicsLayer = MyMap.Layers[1] as GraphicsLayer;
0 Kudos
JenniferNery
Esri Regular Contributor
Your code looks exactly like the 1.2 FeatureDataGrid sample minus the Binding statement. You can debug through it to see if InitializeComponent() is completed. If exception is thrown before it reaches the Binding statements in code-behind, then take one code at a time. Maybe remove VisualStateGroup on your symbol and see if XamlParseException persists.
0 Kudos