hi ,
1) explain the Map_ToolTipOpening event &Map_ToolTipClosing events
with an example
2) and exaplain routed evet with an example
thanks,
Ravi Bokkala
hi ,
1) explain the Map_ToolTipOpening event &Map_ToolTipClosing events
with an example
2) and exaplain routed evet with an example
thanks,
Ravi Bokkala
Hello Ravi,
1) To prevent a tooltip from appearing in the UI, your handler for ToolTipOpening can mark the ToolTipEventArgs event data handled. Otherwise, the tooltip is displayed, using the value of the ToolTip property as the tooltip content. Another possible scenario is that you could write a handler that resets the value of the ToolTip property for the element that is the event source, just before the tooltip is displayed.
ToolTipOpening will not be raised if the value of ToolTip is null or otherwise unset. Do not deliberately set ToolTip to null while a tooltip is open or opening; this will not have the effect of closing the tooltip, and will instead create an undesirable visual artifact in the UI.
The ToolTipOpening event cannot be an EventTrigger in a style. This is because the identifier field of this event re-uses an implementation from a service that does not expose add/remove event methods for the service-level event.
Please have a look this sample, ToolTipClosing is almost as same as ToolTipOpening, so I didn't made a sample for it.
private void WpfMap_Loaded(object sender, RoutedEventArgs e)
{
wpfMap1.MapUnit = GeographyUnit.DecimalDegree;
wpfMap1.CurrentExtent = new RectangleShape(-131.22, 55.05, -54.03, 16.91);
WorldMapKitWmsWpfOverlay worldMapKitOverlay = new WorldMapKitWmsWpfOverlay();
wpfMap1.Overlays.Add(worldMapKitOverlay);
wpfMap1.ToolTipOpening += new ToolTipEventHandler(wpfMap1_ToolTipOpening);
wpfMap1.Refresh();
wpfMap1.ToolTip = "anything?";
}
private void wpfMap1_ToolTipOpening(object sender, ToolTipEventArgs e)
{
wpfMap1.ToolTip = "nothing";
}
2 )Different RoutedEventArgs can be used with a single RoutedEvent. This class is responsible for packaging the event data for a RoutedEvent, providing extra event state information, and is used by the event system for invoking the handler associated with the routed event.
For your custom event to support event routing, you need to register a RoutedEvent using the RegisterRoutedEvent method. This example demonstrates the basics of creating a custom routed event.
public class MyButtonSimple: Button
{
// Create a custom routed event by first registering a RoutedEventID
// This event uses the bubbling routing strategy
public static readonly RoutedEvent TapEvent = EventManager.RegisterRoutedEvent(
"Tap", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MyButtonSimple));
// Provide CLR accessors for the event
public event RoutedEventHandler Tap
{
add { AddHandler(TapEvent, value); }
remove { RemoveHandler(TapEvent, value); }
}
// This method raises the Tap event
void RaiseTapEvent()
{
RoutedEventArgs newEventArgs = new RoutedEventArgs(MyButtonSimple.TapEvent);
RaiseEvent(newEventArgs);
}
// For demonstration purposes we raise the event when the MyButtonSimple is clicked
protected override void OnClick()
{
RaiseTapEvent();
}
}
Regards,
Gary