【问题标题】:Is it possible to obtain a reference to a silverlight's page from a WebPart?是否可以从 WebPart 获得对 silverlight 页面的引用?
【发布时间】:2010-10-15 15:36:25
【问题描述】:

我想知道如何与 Page.xaml.cs 中定义的这个 Page 类进行通信:

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() {}


}

来自在此处创建 silverlight 对象的 webpart:

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);

}

【问题讨论】:

    标签: c# silverlight sharepoint web-parts


    【解决方案1】:

    我不知道您所说的“与这个 Page 类进行交流”到底是什么意思。但我认为您不能直接调用该类或它的实例。您可以做的是将参数传递给 Silverlight 控件,然后可以在控件内部使用。您可以在 Jesse Liberty 的以下博客文章中找到一些相关信息:Passing Parameters Into Silverlight Applications

    希望对你有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-07
      • 2018-05-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多