C# 将2个参数从SharePoint web部件项目传递到Silverlight应用程序中的Silverlight控件
我在SharePoint web部件项目中定义了两个参数,当用户从两个组合框(可浏览属性)中选择时,这些参数将传递到Silverlight应用程序中的应用程序_Startup()。不知何故,当我将Silverlight控件加载到SharePoint网站上时,它不会呈现。传入1个参数后,控件显示无错误。有什么想法吗?语法?例子 App.xaml.cs:C# 将2个参数从SharePoint web部件项目传递到Silverlight应用程序中的Silverlight控件,c#,silverlight,sharepoint-2007,silverlight-2.0,C#,Silverlight,Sharepoint 2007,Silverlight 2.0,我在SharePoint web部件项目中定义了两个参数,当用户从两个组合框(可浏览属性)中选择时,这些参数将传递到Silverlight应用程序中的应用程序_Startup()。不知何故,当我将Silverlight控件加载到SharePoint网站上时,它不会呈现。传入1个参数后,控件显示无错误。有什么想法吗?语法?例子 App.xaml.cs: private void Application_Startup(object sender, StartupEventArgs e) {
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次。无论如何,请使用
if (_setArticles.Equals("_1_article"))
{
retrieveOneListboxItemStaffNews();
GetData3();
}
if (_setArticles.Equals("_2_articles"))
{
retrieveTwoListboxItemStaffNews();
GetData3();
}
if (_setArticles.Equals("_3_articles"))
{
retrieveThreeListboxItemStaffNews();
GetData3();
}
否则将调用
GetData3()
,每次调用3次。感谢您的回复。您知道如何访问嵌入在datatemplate中的textblock吗?在线示例没有太大帮助,因为它涉及到在网格上指定一个x:key?感谢您的回复。您知道如何访问嵌入在datatemplate中的textblock吗?在线示例没有太大帮助,因为它涉及到在网格上指定x:key?