Disable HighlighFill on VisualisationLayer

2 posts, 0 answers
  1. Renier Pretorius
    Renier Pretorius avatar
    46 posts
    Member since:
    Apr 2010

    Posted 29 Jul Link to this post

    Hi,

    I have a map with several Visualisation Layers. One of these represent nodes and another represents the links between the nodes. I want the user to select two nodes and then calculate the route along the links (these are not roads or other routes available through a map provider). Once I have determined all the links in the route I wish to select them. My links are LineData objects which have ShapeFill, SelectedFill and IsSelected properties. Initially I just wanted to set the IsSelected property but it is readonly so I am using the UseSelectedFill method that achieves the desired effect. However, as soon as the user hovers over the link it returns to the regular shapefill.

    Is there a way to disable the highlighting event (while still shopwing the ToolTip) or is there an alternative aproach to take.

    Regards

    Renier

  2. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 02 Aug Link to this post

    Hello Renier,

    You can set the AutoHighlightMapShape property of the VisualizationLayer to False.
    <telerik:VisualizationLayer AutoHighlightMapShape="False">
    Note that this property will disable the highlighting of all shapes in the visualization layer. If you want to forbid the highlighting of specific shapes only, you will need to write custom logic.

    For example, you can subscribe for the MapShapeVisualizationCreated/Removed events of the VisualizationLayer and then subscribe for the MouseEnter event of the shape's presenter. After this you can override the default change of the fill. 
    this.layer.MapShapeVisualizationCreated += layer_MapShapeVisualizationCreated;
    this.layer.MapShapeVisualizationRemoved += layer_MapShapeVisualizationRemoved;
    //......
    void layer_MapShapeVisualizationRemoved(object sender, MapShapeOperationEventArgs e)
    {
        e.Visualization.MouseEnter -= Visualization_MouseEnter;
    }
     
    void layer_MapShapeVisualizationCreated(object sender, MapShapeOperationEventArgs e)
    {
        e.Visualization.MouseEnter += Visualization_MouseEnter;
    }
     
    void Visualization_MouseEnter(object sender, MouseEventArgs e)
    {
        var presenter = (ContentPresenter)sender;
        var data = (MapShapeData)presenter.DataContext;
        if (data.IsSelected)
        {
            data.UseSelectedFill();
        }
        else
        {
            data.UseRegularFill();
        }
    }

    Regards,
    Martin
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. DevCraft banner
Back to Top