问题描述
我在SharePoint Web部件项目中定义了2个参数,当用户从2个组合框(可浏览的属性)中进行选择时,这些参数将传递到Silverlight应用程序的Application_Startup()中.当我将其加载到SharePoint网站上时,Silverlight控件无法以某种方式呈现.传入1个参数后,控件将显示无错误.有任何想法吗?句法?例子吗?
I have 2 parameters defined in SharePoint web part project, meant to be passed into Application_Startup() in a Silverlight application when a user selects from 2 combo boxes (browsable properties). Somehow the Silverlight control does not render when i load it on the SharePoint site. With 1 parameter passed in, the control displays without error. Any ideas? Syntax? Examples?
App.xaml.cs:
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:
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:
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次.
otherwise GetData3()
will be called anyway, 3 times each time.
这篇关于将2个参数从SharePoint Web部件项目传递到Silverlight控件到Silverlight应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!