加载组件时出错

时间:2012-09-26 15:13:10

标签: silverlight

我正在将Silverlight 3项目转换为Silverlight 4.我最近让项目能够运行,但是我遇到了实例化搜索窗口的问题。 VS向我提出以下错误:

Microsoft JScript runtime error: Unhandled Error in Silverlight Application Set property 'System.Windows.FrameworkElement.Style' threw an exception. [Line: 242 Position: 46]   at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
   at ESM.Visualization.SearchWindow.InitializeComponent()
   at ESM.Visualization.SearchWindow..ctor(Map mapWindow, String addressServiceUrl, String projectServiceUrl)
   at ESM.Visualization.MainPage.InstantiateSearchWindow()
   at ESM.Visualization.MainPage.MapWindow_Progress(Object sender, ProgressEventArgs e)
   at ESRI.ArcGIS.Client.Map.layersProgressHandler(Object sender, ProgressEventArgs args)
   at ESRI.ArcGIS.Client.LayerCollection.layer_OnProgress(Object sender, ProgressEventArgs args)
   at ESRI.ArcGIS.Client.Layer.ProgressHandler.Invoke(Object sender, ProgressEventArgs args)
   at ESRI.ArcGIS.Client.Layer.OnProgress(Int32 progress)
   at ESRI.ArcGIS.Client.DynamicLayer.bitmap_DownloadProgress(Object sender, DownloadProgressEventArgs e, Image img, EventHandler`1 onProgressEventHandler, Int32 id)
   at ESRI.ArcGIS.Client.DynamicLayer.<>c__DisplayClass7.<getSourceComplete>b__4(Object sender, DownloadProgressEventArgs e)
   at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)

我研究了错误,并尝试按照this solution重新安装Silverlight。但错误仍然发生。我看了this SO question,但我的App.xaml不是242行。这是我在第242行附近的MainPage.xaml:

<StackPanel Orientation="Vertical" HorizontalAlignment="Left" Grid.Row="2" VerticalAlignment="Bottom">
            <esriToolkit:Navigation x:Name="MapNavigation" Margin="5" Map="{Binding ElementName=MapWindow}" Visibility="Collapsed"  />
            <!--<esri:ScaleBar x:Name="MainScaleBar" Margin="5" MapUnit="DecimalDegrees" Foreground="Black" 
                Map="{Binding ElementName=MapWindow}"
                DisplayUnit="Miles" Visibility="Visible" />-->
</StackPanel>

这是我试图实例化的搜索窗口的.xaml(在第242行附近):

<grid:AgDataGrid x:Name="grdAddressResults" Grid.Row="1" Grid.Column="0" ColumnsAutoWidth="True"
                                 ShowTotals="False" FocusMode="Row" FocusedRowChanged="grdResults_FocusedRowChanged"
                                 IsMultiSelect="False" Margin="0,10,0,0">
                                <grid:AgDataGrid.Columns>
                                    <grid:AgDataGridColumn FieldName="Address" />
                                    <grid:AgDataGridColumn FieldName="X" Visible="False" />
                                    <grid:AgDataGridColumn FieldName="Y" Visible="False" />
                                </grid:AgDataGrid.Columns>
                                <grid:AgDataGrid.TotalSummary>
                                    <grid:AgDataGridSummaryItem FieldName="Address" SummaryType="Count" Title="Matches Found" />
                                </grid:AgDataGrid.TotalSummary>
                            </grid:AgDataGrid>

1 个答案:

答案 0 :(得分:1)

异常告诉

  

设置属性'System.Windows.FrameworkElement.Style'引发异常。

虽然这不在您显示的代码中 - 但我几乎可以肯定您会在代码中找到类似的内容:

<SomeControl Style="MyCoolStyle" ... />

应该是:

<SomeControl Style="{StaticResource MyCoolStyle}" ... />