views:

136

answers:

1

Hi,

I have a problem using custom made UserControl in Silverlight Page. The UserControl is generally a rectangle containing a smaller rectangle inside. I want to use the UControl in a Silverlight MainSite. i've implemented a method on mouse button down for a smaller rectangle called in here Button1:

public void Button1_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
    {
     MessageBox.Show("Hello");
    }

How can i use it from a MainSite? From there I can only implement a method like:

private void ImportedControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        firstLeaf.Button1_MouseLeftButtonDown(sender, e);
    }

I can not implement a method for Button1.

How can i mek this Work? HELP:)

A: 

I am still not sure I understand the question, but let me take a swing at an answer. Why don't you use a real Button and just template it with a rectangle? This way you get all the benefits of actually having a button while having it look like a rectangle, including the Click event.

Here is a post Scott Guthrie did on control templating with a button.

Jason Jackson