将SharePoint web部件项目中的2个参数传递给Silverlight控件到Silverlight应用程序



我在SharePoint web部件项目中定义了2个参数,当用户从2个组合框(可浏览属性)中进行选择时,它们将传递给Silverlight应用程序中的Application_Startup()。不知何故,当我在SharePoint网站上加载Silverlight控件时,它不呈现。传入1个参数后,控件显示无误。什么好主意吗?语法呢?例子吗?

App.xaml.cs:

private void Application_Startup(object sender, StartupEventArgs e)
{
    //testing
    string _setArticles = null;
    string _setLength = null;
    if (e.InitParams != null && e.InitParams.Count >= 1)
    {
        _setArticles = e.InitParams["_setArticles"];
        _setLength = e.InitParams["_setLength"];
    }
    this.RootVisual = new Page(_setArticles, _setLength);
}

Page.xaml.cs:

public Page(string _setArticles, string _setLength)
{
    InitializeComponent();
    //(number of items to display on load)
    if (!string.IsNullOrEmpty(_setArticles) && !string.IsNullOrEmpty(_setLength) )
    {
        if (_setArticles.Equals("_1_article"))                   
            retrieveOneListboxItemStaffNews();
            GetData3();
        if (_setArticles.Equals("_2_articles"))
            retrieveTwoListboxItemStaffNews();
            GetData3();
       if (_setArticles.Equals("_3_articles"))
            retrieveThreeListboxItemStaffNews();
            GetData3();
       //testing
       //send value to method 'fullNameControl_Loaded' (summary length of each ListBox item)                    
       if (_setLength.Equals("_3_lines"))
            m_textBlock.MaxHeight = 40;
       if (_setLength.Equals("_4_lines"))
            m_textBlock.MaxHeight = 50;
       if (_setLength.Equals("_5_lines"))
            m_textBlock.MaxHeight = 65;  
    }
}

SilverlightSecondWebPart.cs:

protected override void CreateChildControls()
{
    base.CreateChildControls();
    //silverlight control
    silverlightControl = new Silverlight();
    silverlightControl.ID = "News";
    silverlightControl.Source = "/ClientBin/News.xap";
    silverlightControl.Width = new System.Web.UI.WebControls.Unit(800);
    silverlightControl.Height = new System.Web.UI.WebControls.Unit(550);

    //testing
    string parameters =  "_setArticles=" + _myEnum + ", " + "_setLength=" + _myEnum2;
    silverlightControl.InitParameters = parameters;
    silverlightControl.MinimumVersion = "2.0";
    Controls.Add(silverlightControl);
}  

无论如何

if (_setArticles.Equals("_1_article"))
{
    retrieveOneListboxItemStaffNews();
    GetData3();
}
if (_setArticles.Equals("_2_articles"))
{
    retrieveTwoListboxItemStaffNews();
    GetData3();
}
if (_setArticles.Equals("_3_articles"))
{
    retrieveThreeListboxItemStaffNews();
    GetData3();
}

否则GetData3()无论如何都会被调用,每次调用3次

相关内容

  • 没有找到相关文章