简体   繁体   English

用户代码未处理通用转换 InvalidOperation 异常

[英]Gerneral Transform InvalidOperation Exception was unhandled by user code

I have ran into a problem that I am completely clueless about.我遇到了一个我完全不知道的问题。 I am receiving the following error message:我收到以下错误消息:

The specified Visual and the Visual do not share a common ancestor, so there is no valid transformation between the two visuals.指定的 Visual 和 Visual 不共享共同的祖先,因此两个视觉对象之间没有有效的转换。

This is being called when the user clicks on a point on the map.当用户点击地图上的一个点时会调用它。 Any help would be appreciated.任何帮助,将不胜感激。 I have attached snippets of the error.我附上了错误的片段。 If you need anymore code samples, just let me know.如果您需要更多代码示例,请告诉我。

Here is my relevant XAML:这是我的相关 XAML:

(<)inf:DialogWindowBase x:Class="Alliance.CommonUI.Views.Maps.EsriMapView" (<)inf:DialogWindowBase x:Class="Alliance.CommonUI.Views.Maps.EsriMapView"

<Grid>

<Grid>
 <DataTemplate x:Key="MyFeatureLayerInfoWindowTemplate">
                    <TextBlock Text="Content" Foreground="White" FontSize="12" />
                </DataTemplate>
                <esri:SimpleRenderer x:Key="MySimpleRenderer">
                    <esri:SimpleRenderer.Symbol>
                        <esri:SimpleFillSymbol Fill="#01FFFFFF" BorderBrush="#88000000" BorderThickness="2" />
                    </esri:SimpleRenderer.Symbol>
                </esri:SimpleRenderer>
 </Grid.Resources>

            <esri:Map x:Name="MyMap" Background="#FFE3E3E3" WrapAround="True" MouseClick="MyMap_MouseClick" MouseRightButtonDown="MyMap_MouseRightButtonDown" Extent="-9834972.92753924,4441899.425293319,-9833977.88119163, 4442762.485358352">
                <esri:ArcGISTiledMapServiceLayer ID="MyLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
                <!--<esri:ArcGISLocalDynamicMapServiceLayer ID="Calvert_City" Path="C:\Users\jessical\Documents\ArcGIS\CalvertCity_Test.mpk"/>-->
                <esri:ArcGISDynamicMapServiceLayer  ID="Calvert_City" Url="http://localhost:6080/arcgis/rest/services/CalvertCity_Test_2/MapServer"/>
                <esri:FeatureLayer ID="MyFeatureLayer"  Url="http://localhost:6080/arcgis/rest/services/CalvertCity_Test_2/MapServer/0"
                            Renderer="{StaticResource MySimpleRenderer}" />
</esri:Map>

            <Border Background="{StaticResource PanelGradient}" BorderThickness="1" CornerRadius="5"
            HorizontalAlignment="Left"  VerticalAlignment="Top"
            Margin="20" Padding="5" BorderBrush="Black" >
                <esri:Legend Map="{Binding ElementName=MyMap}"
                         LayerIDs="Calvert_City"
                         LayerItemsMode="Tree"
                         ShowOnlyVisibleLayers="False"
                         Refreshed="Legend_Refreshed">
                    <esri:Legend.MapLayerTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <CheckBox Content="{Binding Label}"
                                    IsChecked="{Binding IsEnabled, Mode=TwoWay}"
                                    IsEnabled="{Binding IsInScaleRange}" >
                                </CheckBox>
                                <Slider Maximum="1" Value="{Binding Layer.Opacity, Mode=TwoWay}" Width="50" />
                            </StackPanel>
                        </DataTemplate>
                    </esri:Legend.MapLayerTemplate>
                    <esri:Legend.LayerTemplate>
                        <DataTemplate>
                            <CheckBox Content="{Binding Label}"
                            IsChecked="{Binding IsEnabled, Mode=TwoWay}"
                            IsEnabled="{Binding IsInScaleRange}" >
                            </CheckBox>
                        </DataTemplate>
                    </esri:Legend.LayerTemplate>
                </esri:Legend>
            </Border>
            <esri:InfoWindow x:Name="MyInfoWindow"
                         Padding="2"
                         CornerRadius="20"
                         Background="{StaticResource PanelGradient}"
                         Map="{Binding ElementName=MyMap}"
                         ContentTemplate="{StaticResource MyFeatureLayerInfoWindowTemplate}"
                         MouseLeftButtonUp="MyInfoWindow_MouseLeftButtonUp" />

在此处输入图片说明在此处输入图片说明

I was getting this error using a third party control from SciChart.我使用来自 SciChart 的第三方控件收到此错误。 I found that the error was being thrown under the covers and the debugger would make it look like the error was not being handled.我发现错误被掩盖了,调试器会让它看起来好像没有处理错误。 However, when I just turned off break on this type of exception and put a break point in my catch statement, the exception did not fall into my catch block.但是,当我刚刚关闭了此类异常的 break 并在我的 catch 语句中放置了一个断点时,该异常并没有落入我的 catch 块中。 I'm somewhat confused by all of this, but it seems to be working.我对这一切感到有些困惑,但它似乎正在起作用。

So my suggestion is to have the debugger not break on this type of exception and see how that works.所以我的建议是让调试器不要因为这种类型的异常而中断,看看它是如何工作的。

You're using TransformToVisual.您正在使用 TransformToVisual。 It should be TransformToAncestor.它应该是 TransformToAncestor。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM