zoukankan      html  css  js  c++  java
  • Silverlight学习笔记1:创建一个Silverlight应用程序

         以VS2010作为开发工具,首先启动Visual Studio,然后点击“文件”-->“新建项目”,在模版中选择silverlight,输入名称点确定后在新弹出窗口中选择silverlight版本,创建一个SilverlightSimple1的项目。

    1.新建项目后分为两个部分:

       a. asp.net网站项目

            新建后包含以下文件:

             Silverlight.js  :提供一些 JavaScript 帮助器函数,这些函数用于将 Silverlight 插件嵌入某一网页和用于自定义 Silverlight 安装体验。

             SilverlightSimple1TestPage.aspx和 SilverlightSimple1TestPage.html一样都是用来承载silverlight应用程序的测试页。  

             Web.config asp.net网站项目的配置文件

       b.应用程序项目

            应用程序中会产生两个xaml文件,分别是App.xaml和MainPage.xaml以及相应的App.xaml.cs和MainPage.xaml.cs

    3.创建应用程序

     (1).修改xaml中页面宽度和高度分别为300和400像素,并在<Grid>..</Grid>中加入TextBlock元素,设置其字体,代码如下:

     1 <UserControl x:Class="SilverlightSimple1.MainPage"
    2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    4 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    5 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    6 mc:Ignorable="d"
    7 d:DesignHeight="300" d:DesignWidth="400">
    8
    9 <Grid x:Name="LayoutRoot" Background="White">
    10 <TextBlock Text="文本显示" FontFamily="宋体" Foreground="Blue" FontSize="12"></TextBlock>
    11 </Grid>
    12 </UserControl>

     (2).修改填充色(实现简单的填充效果)

    <UserControl x:Class="SilverlightSimple1.MainPage"
    xmlns
    ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x
    ="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d
    ="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc
    ="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable
    ="d"
    d:DesignHeight
    ="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
    <TextBlock Text="文本显示" FontFamily="宋体" FontSize="12">
    <!-- 使用渐变画刷填充文本产生渐变效果-->
    <TextBlock.Foreground>
    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
    <GradientStop Color="Black"></GradientStop>
    <GradientStop Color="White" Offset="1"></GradientStop>
    </LinearGradientBrush>
    </TextBlock.Foreground>
    </TextBlock>
    </Grid>
    </UserControl>

      LinearGradientBrush :线性渐变填充属性元素。

      GradientStop:控制渐变颜色由黑到白,

      EndPoint ,StartPoint:控制渐变角度

      Offset:控制渐变范围

      最终效果如下: 

         Silverlight项目也可在浏览器外进行访问,进行设置只需选中工程,右键属性,将“允许浏览器外运行程序”选项勾选即可脱离浏览器进行访问。


  • 相关阅读:
    双反斜杠引发的正则表达式错误
    表单验证的前端验证后端验证
    html中的select下拉框
    hibernate需要注意的点
    星空雅梦
    星空雅梦
    星空雅梦
    星空雅梦
    星空雅梦
    星空雅梦
  • 原文地址:https://www.cnblogs.com/tanliang/p/2183784.html
Copyright © 2011-2022 走看看