views:

60

answers:

1

Hi. I'm wondering how to communicate with this Page class defined in Page.xaml.cs:

public partial class Page : UserControl
{
    public Page()
    {
        InitializeComponent();
    }

    private void TextBlock_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {
        if (HelloWorldTextBlock.Text == "Hello World")
            HelloWorldTextBlock.Text = "I've been clicked";
        else
            HelloWorldTextBlock.Text = "Hello World";
    }
    public void foo() {}


}

From a webpart that creates the silverlight object here:

protected override void CreateChildControls()
{
     base.CreateChildControls();

     System.Web.UI.SilverlightControls.Silverlight ctrl = new System.Web.UI.SilverlightControls.Silverlight();
     ctrl.ID = "SLHelloWorld";
     ctrl.Source = SPContext.Current.Site.Url + "/XAPS/SL.XAML.HelloWorldRTM.xap";
     ctrl.Width = new Unit(400);
     ctrl.Height = new Unit(310);
     Controls.Add(ctrl);

}
+1  A: 

Hi,

I don't know what you exactly mean with "to communicate with this Page class". But I don't think you can call the class or an instance of it directly. What you can do, is passing parameters to the Silverlight control, which can then be used inside the control. You can find some infos on this in the following blog post form Jesse Liberty: Passing Parameters Into Silverlight Applications

I hope this might help you.

Flo