Graphic g = e.Graphic; MapTipsPanel mt = new MapTipsPanel(); mt.lblFieldName.Text = fn; //this is field name coming from some where else mt.txtLyrName.Text = lyeName; //this is layer name coming from some where else string maptipsValue= Convert.ToString(g.Attributes[fn]); mt.txtFieldValue.Text = maptipsValue + " " + suffixVal; fl.MapTip = mt;
<Grid x:Name="LayoutRoot" Width="auto" Height="70"> <Border CornerRadius="10" BorderBrush="#FF222957" BorderThickness="3" > <Border.Background> <LinearGradientBrush EndPoint="1.038,1.136" StartPoint="0.015,0.188"> <GradientStop Color="#FFD1DFF2"/> <GradientStop Color="#FF0088FF" Offset="0.946"/> </LinearGradientBrush> </Border.Background> <StackPanel Orientation="Vertical"> <TextBlock x:Name="txtLyrName" Height="20" Width="auto" Margin="5,5,5,0" Text="Layer Name"/> <TextBlock x:Name="lblFieldName" Height="20" Width="auto" Margin="5,0,5,0" Text=" Field name" /> <TextBlock x:Name="txtFieldValue" Height="20" Width="auto" Margin="5,0,5,0" Text=" Attr value" /> </StackPanel> </Border> </Grid>
when I am implementing this on designtime maptip is coming but not @ runtime
System.Windows.Data.Binding binding = new System.Windows.Data.Binding("[CITY_NAME]");
This is how I implemented maptips @runtime.
1. I subscribed to the mouse enter event of the feature layer and used following code.Graphic g = e.Graphic; MapTipsPanel mt = new MapTipsPanel(); mt.lblFieldName.Text = fn; //this is field name coming from some where else mt.txtLyrName.Text = lyeName; //this is layer name coming from some where else string maptipsValue= Convert.ToString(g.Attributes[fn]); mt.txtFieldValue.Text = maptipsValue + " " + suffixVal; fl.MapTip = mt;
Note that MapTipsPanel in above code is a separate user control and its xaml is as below.
XAML:<Grid x:Name="LayoutRoot" Width="auto" Height="70"> <Border CornerRadius="10" BorderBrush="#FF222957" BorderThickness="3" > <Border.Background> <LinearGradientBrush EndPoint="1.038,1.136" StartPoint="0.015,0.188"> <GradientStop Color="#FFD1DFF2"/> <GradientStop Color="#FF0088FF" Offset="0.946"/> </LinearGradientBrush> </Border.Background> <StackPanel Orientation="Vertical"> <TextBlock x:Name="txtLyrName" Height="20" Width="auto" Margin="5,5,5,0" Text="Layer Name"/> <TextBlock x:Name="lblFieldName" Height="20" Width="auto" Margin="5,0,5,0" Text=" Field name" /> <TextBlock x:Name="txtFieldValue" Height="20" Width="auto" Margin="5,0,5,0" Text=" Attr value" /> </StackPanel> </Border> </Grid>
This worked for me. Hope this helps.
Well, in my opinion, it should not work for the clusterer. Because, clusterer means you are hiding some point features and displaying few points to represent them. So, when mouse enter event is fired, it would not know which graphic is below the mouse.
That's what I think.
@Dominique,
Actually I had tried your approach earlier and it worked when I put literal field name in [ ]. But when I put the string variable representing the field name in [ ], it did not work. That's why I took another approach. Can you please explain this behaviour?