tags:

views:

49

answers:

3

Hello,

I have a canvas on my page and when i click a button i'm creating a new button dynamically on my canvas. So, i whant to keep my button somewhere where i can access anytime anywhere on my project( to change text for example, or to format it).Can someone give me a solution?

+1  A: 

This type of functionality is usually done via callbacks (delegates) on your page / form or tied to your control.

Have whatever you want to trigger the change, register to some event you have defined with your button/textbox/page.

Kelsey
+1  A: 

Silverlight runs completely on the client, inside the browser, so there's no need to worry about storing things in session state on the server. Well, unless you are posting back to the server from within your app, but there's no indication in your question that you're doing that.

If you create a button in Silverlight (from a page or control), it will be available to you in that page or control just like any regular old .NET variable. If it's declared as a field, you can get at it from anywhere.

public partial class MainControl : UserControl
{
    private Button myButtonToKeepAroundAllTheTime;

    protected void TriggerButton_Click(object sender, EventArgs e)
    {
        myButtonToKeepAroundAllTheTime = new Button()
        {
            Content = "Click Me",
            Height = 20
        };
    }
}
Brad Tutterow
A: 

OK, but if a have more components on my canvas and I whant to store the last clicked component somewhere...and my component can be button, image, textbox, etc. How can i do that? In what can i store mt component and get it when i need it.? Thanks.

Andrei Bularca