将最美的计算机软件奉献给社会

博客园 首页 新随笔 联系 订阅 管理

第一步:创建一个要使用Silverlight的网页,MyFirstSilverlight.html,代码如下:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-

transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Silverlight显示文本</title>
    <script type="text/javascript" src="Silverlight.js"></script>
    <script type="text/javascript" src="MyFirstSilverlight.html.js"></script>
    <script type="text/javascript" src="MyFirstSilverlight.xaml.js"></script>
</head>
<body>
silverlight is very good !
<br /><br />

<!--用来显示silverlight plugin 区域-->
<div id="SilverlightControlHost">
    <script type="text/javascript">
        createSilverlight();
    </script>
</div>

<br /><br />
silverlight is very good !

</body>
</html>

 

第二步:创建实现createSilverlight()方法的页面MyFirstSilverlight.html.js,代码如下:

 

function createSilverlight()
{
    Silverlight.createObjectEx({
    source:'MyFirstSilverlight.xaml',
    parentElement: document.getElementById('SilverlightControlHost'),
    id:'SilverlightControlHost',
    properties:{
    width:'800',
    height:'550',
    background:'lightblue',
    isWindowless:'false',
    version:'1.0'
    },
    events:
    {},
    context:null
    });
}

if(!window.Silverlight)
{
    window.Silverlight = {};
}

Silverlight.createDelegate = function(instance,method){
return function(){
return method.apply(instance,arguments);
}
}

 

第三步:创建一个Silverlight内容页面MyFirstSilverlight.xaml,代码如下:

 

<Canvas xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Canvas Canvas.Left="20" Canvas.Top="20">

    <TextBlock Canvas.Left="10" Canvas.Top="10"  Foreground="#ff5566" Text="hello silverlight" />
    <Rectangle Width="200" Height="150" Fill="Orange" Canvas.Left="10" Canvas.Top="30"></Rectangle>
    <Rectangle Width="180" Height="130" Fill="Green" RadiusX="10" RadiusY="10" Canvas.Left="20" Canvas.Top="40"></Rectangle>
    <TextBlock  Canvas.Left="30" Canvas.Top="50"  Foreground="red" Text="圆角效果不错吧" />
    <TextBlock  Canvas.Left="50" Canvas.Top="70"  Foreground="red" Text="圆角效果不错吧" />
    <Ellipse Width="150" Height="150" Fill="Purple" Canvas.Top="30" Canvas.Left="300"></Ellipse>
   
    <TextBlock Canvas.Left="10" Canvas.Top="200" Opacity="0.2" Foreground="red" Text="Opacity属性设置的透明效果"></TextBlock>
    <TextBlock Canvas.Left="10" Canvas.Top="220" Opacity="0.4" Foreground="red" Text="Opacity属性设置的透明效果"></TextBlock>
    <TextBlock Canvas.Left="10" Canvas.Top="240" Opacity="0.7" Foreground="red" Text="Opacity属性设置的透明效果"></TextBlock>
    <TextBlock Canvas.Left="10" Canvas.Top="260" Opacity="0.9" Foreground="red" Text="Opacity属性设置的透明效果"></TextBlock>

    <TextBlock Canvas.Left="10" Canvas.Top="280"  Foreground="red" FontWeight="Bold">字体已加粗了</TextBlock>
    <TextBlock Canvas.Left="10" Canvas.Top="300"  Foreground="red" FontWeight="ExtraBold">字体更加粗了</TextBlock>

    <TextBlock Canvas.Left="10" Canvas.Top="330" TextWrapping="Wrap">
      1、正规大学计算机相关专业本科以上学历;
      2、至少4年以上Flash开发与设计经验;
      3、精通XML,精通Java script;
      4、熟悉c#者优先,熟悉Silverlight、具备Expression Blend设计经验者优先;
      5、良好的英文读写能力,CET-6优先
      <!--文本剪切-->
      <TextBlock.Clip>
        <EllipseGeometry Center="200,100" RadiusX="150" RadiusY="150"></EllipseGeometry>
      </TextBlock.Clip>
    </TextBlock>

    <TextBlock Canvas.Left="10" Canvas.Top="400" Foreground="yellow" >
      良好的英文读写能力,
      <!--突出特定文本-->
      <Run Foreground="red" FontWeight="ExtraBold">
        CET-6
      </Run>
      优先
    </TextBlock>
 

  </Canvas>
</Canvas>

posted on 2010-09-25 17:32  赖顺生  阅读(234)  评论(0编辑  收藏  举报