首页 新闻 会员 周边

silverlight 新手问题

0
悬赏园豆:100 [已解决问题] 解决于 2012-03-27 18:02

版本VS2010+silverlight5

1.关于控件,<line/>手动输入是有的,为什么工具箱里看了一遍没有?还有<watermarkedTextbox/>好多教程里有,我的没有?

2.原来的工程里没有用到silverlight,现在想把silverlight加到原来的工程里,它是如何和原来的工程交换数据的?给个例子行吗,谢谢!~

happydaily的主页 happydaily | 菜鸟二级 | 园豆:301
提问于:2012-03-25 09:06
< >
分享
最佳答案
1

watermarkedTextbox这个需要安装toolkit包,http://silverlight.codeplex.com/

数据交换可以使用WCF RIA Service 可参考 http://www.cnblogs.com/2018/category/262512.html http://www.cnblogs.com/2018/category/249771.html 

收获园豆:70
2012 | 高人七级 |园豆:21230 | 2012-03-25 09:55
其他回答(2)
1

<line/> 在工具箱都看不到。

自定義的watermarkedtestbox

View Code
   public class WatermarkedTextBox : TextBox
{
public static readonly DependencyProperty DefaultTextProperty = DependencyProperty.Register("DefaultText", typeof(string), typeof(WatermarkedTextBox), new PropertyMetadata(""));
public event EventHandler WatermarkedTextChanged;

public WatermarkedTextBox()
{
base.TextChanged += new TextChangedEventHandler(this.OnWotermarkedTextBoxTextChanged);
}

public override void OnApplyTemplate()
{
base.Text = this.DefaultText;
base.OnApplyTemplate();
}

protected override void OnGotFocus(RoutedEventArgs e)
{
if (string.Equals(base.Text, this.DefaultText, StringComparison.OrdinalIgnoreCase))
{
base.Text = string.Empty;
}
base.OnGotFocus(e);
}

protected override void OnLostFocus(RoutedEventArgs e)
{
if (string.IsNullOrEmpty(base.Text))
{
base.Text = this.DefaultText;
}
base.OnLostFocus(e);
}

private void OnWotermarkedTextBoxTextChanged(object sender, TextChangedEventArgs e)
{
if (!string.Equals(base.Text, this.DefaultText, StringComparison.OrdinalIgnoreCase))
{
if(this.WatermarkedTextChanged != null)
this.WatermarkedTextChanged(this, e);
}
}

public string DefaultText
{
get
{
return (string)base.GetValue(DefaultTextProperty);
}
set
{
base.SetValue(DefaultTextProperty, value);
}
}
}



關於2.你只要新增一個silverlight項目,就會生成一個 測試代碼,有asp.net調用。和 html調用。你只要按照這個做就好了。包括js,和ClientBin文件夾下的內容。

收获园豆:20
無限遐想 | 园豆:3740 (老鸟四级) | 2012-03-25 09:59
0

..这也太新了吧。

2.原来的工程里没有用到silverlight,现在想把silverlight加到原来的工程里,它是如何和原来的工程交换数据的?给个例子行吗

 silverlight他是生成一个。xap文件。aspx和html调用这个文件就行。你可以在silverlight项目中,查看项目属性。在生成=》输出路径中,获取和修改生成路径。生成后在路径下面会找到一个。xap文件。在页面用object标签引用就行了。如: <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="1024px">
    <param name="source" value="text/nqm.xap"/>---指定xap源地址

收获园豆:10
在水_方 | 园豆:284 (菜鸟二级) | 2012-03-26 16:33
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册