Hi,
I am encountering an exception while panning XamMap control. I worked with 2010.2 build earlier it was working fine. But in the latest release 2010.3 I am getting an exception, details are as follows.
Message: Element is already the child of another element.
Stack Trace: at MS.Internal.XcpImports.CheckHResult(UInt32 hr) at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh) at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj) at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value) at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue) at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation) at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet) at System.Windows.Controls.ToolTipService.ConvertToToolTip(Object o) at System.Windows.Controls.ToolTipService.RegisterToolTip(UIElement owner, Object toolTip) at System.Windows.Controls.ToolTipService.OnToolTipPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
also attaching the screen shot of the incident.
Thanks,
Sudheer CV
Hi Sudheer,
Would you please provide some sample code where you get the exception on (XAML and\or Code Behind)? This will make it easier to investigate the issue.
Milana Zhileva
As stated in eariler post I am using an user control as tooltip which is causing for the issue.
This is my mark up for ToolTip User control.
<Grid x:Name="LayoutRoot" Background="White" Margin="0,5,0,5" >
<Grid.ColumnDefinitions>
<ColumnDefinition ></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions >
<RowDefinition Height="20"></RowDefinition>
</Grid.RowDefinitions>
</Grid>
This is my Code behind.
public UCToolTip()
{InitializeComponent();}
public UCToolTip(List<Dictionary<string, string>> list)
{
InitializeComponent();
for (int i = 0; i < list.Count; i++)
List<string> listKeys = new List<string>();
listKeys = list[i].Keys.ToList();
for (int j = 0; j < listKeys.Count; j++)
RowDefinition rd = new RowDefinition()
Height =
GridLength.Auto,
};
TextBlock tb1 = new TextBlock();
tb1.Text = listKeys[j];
TextBlock tb2 = new TextBlock();
tb2.Text = list[i][listKeys[j]];
LayoutRoot.RowDefinitions.Add(rd);
Border br1 = new Border()
BorderBrush =
new SolidColorBrush(Colors.Black),
Child = tb1,
BorderThickness =
new Thickness(0),
Padding =
new Thickness(2),
Border br2 = new Border()
Child = tb2,
LayoutRoot.Children.Add(br1);
LayoutRoot.Children.Add(br2);
Grid.SetRow(br1, j);
Grid.SetColumn(br1, 0);
Grid.SetRow(br2, j);
Grid.SetColumn(br2, 1);
}
It is good to hear that the problem has been solved.
As to the issue with your sample code described above, it will be resolved in our next Service Release. Sorry for the inconvenience and please feel free to post back should you need any additional information.
Best regards,Milana Zhileva
Hi Milana,
My problem has solved with your suggestion.
But my doubt is why it is causing problem with my way?
It was good with earlier version of XamMap.
Hi Milana Zhileva,
Please look into my code.
private void BindToolTip(List<Dictionary<string, string>> list)
int j = 0;
List<Dictionary<string, string>> listParam = new List<Dictionary<string, string>>();
foreach (MapElement ele in xamMap.Layers[0].Elements)
if (ele.GetType() == typeof(Infragistics.Controls.Maps.SymbolElement))
list = globalList.Where(ID => ID["type"] == "Stores" && ID["storeid"] == ele.Name).ToList<Dictionary<string, string>>();
j = 0;
Dictionary<String, String> d = new Dictionary<string, string>();
LayerName = list[j]["type"];
d[LayerName] = list[j]["AreaID"];
//d["AreaID"] = list[j]["AreaID"];
if (list[j]["type"] != "Stores")
d["ShapeID"] = list[j]["ShapeID"];
else
d["StoreID"] = list[j]["storeid"];
listParam.Clear();
listParam.Add(d);
ele.ToolTip = new UCToolTip(listParam);
j++;
Thank you for the sample code you provided.
We tried to reproduce this by using your code but no exceptions were thrown.
XAML:
<Grid x:Name="LayoutRoot" Background="White"> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="auto"/> </Grid.RowDefinitions> <igMap:XamMap x:Name="MyMap" Width="800" Height="600" Grid.Row="0" > <igMap:XamMap.Layers> <igMap:MapLayer x:Name="world" FillMode="RandomSelect"> <igMap:MapLayer.Reader> <igMap:ShapeFileReader Uri="world/world"/> </igMap:MapLayer.Reader> </igMap:MapLayer> </igMap:XamMap.Layers> </igMap:XamMap> <Button x:Name="btnSetToolTip" Content="Set Tooltip" Width="100" Click="btnSetToolTip_Click" Grid.Row="1"/> </Grid> CB:
private void btnSetToolTip_Click(object sender, RoutedEventArgs e) { ToolTip mapTip = new ToolTip();
foreach (MapElement mapE in this.MyMap.Layers[0].Elements) { var list = new List<Dictionary<string, string>> { new Dictionary<string, string> { { "text 1", "3"}, {"text 2", "5"} } };
UCToolTip toolTip = new UCToolTip(list); System.Windows.Controls.ToolTip myMapTip = new System.Windows.Controls.ToolTip();
myMapTip.Content = toolTip as UserControl; mapE.ToolTip = myMapTip; }where UCToolTip is the UserControl from the code you provided.
Are you setting the ToolTip in a different way from the one shown above?