troubleshooting Question

Silverlight data binding to septate class c#

Avatar of BrentDenny
BrentDennyFlag for Afghanistan asked on
ASP.NET.NET ProgrammingC#
20 Comments1 Solution693 ViewsLast Modified:
I have a canvas that i need to add some mouse events like mouse-leave and mouse-enter  ect...

i have a separate class that is  will be handling the mouse events but i need to bind them from that page to the separate class NOT to code behind. Here is were i have bound to the class USAmap
i have used it and it works just fine for properties  but I dont now how to bind the mouse events for a canvas.
        <ViewModel:USAmap x:Key="ViewModel" MapItemName="USmap"/>
    <Grid x:Name="LayoutRoot" DataContext="{Binding Source = {StaticResource ViewModel}}">

<Canvas x:Name="Washington" Width="600" Height="398" Canvas.Left="0" Canvas.Top="0">
                    <Path x:Name="Path" Width="72.6667" Height="52.6219" Canvas.Left="38.831" Canvas.Top="19.7767" Stretch="Fill" Fill="#671BA51B" Data="F1 M 38.831,51.7767L ect...."/>

Also is there a way to still find out what the sender is and access it.
to change its properties once clicked. like in the code example

public class USAmap ......

 public static MouseButtonEventHandler _routedEvent;

public void c_MouseMove(object sender, MouseEventArgs e)
            Canvas c = sender as Canvas;

            if (!string.IsNullOrEmpty(c.Name))
                if (c.Name != lastSelected)
                 //   HideMenu();

                lastSelected = c.Name;
                lastSelected2 = c.Name + "_HotSpot";
               // Canvas selectedCanvas2 = this.FindName(lastSelected2) as Canvas;

              //  SetCanvasColor(c, Color.FromArgb(255, 127, 255, 0), 2, Colors.Green, selectedCanvas2);

Open in new window


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 20 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 20 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros