第一个Silverlight程序,绘制一个长方型、一个椭圆、画一条线

第一个Silverlight程序,绘制一个长方型、一个椭圆、画一条线,第1张

概述 第一个Silverlight程序绘制一个长方型、一个椭圆、画一条线 1、首先新建一个Silverlight程序,然后新建一个UserControl页面命名为whatxaml.xaml,在前台绘制图形: <UserControl x:Class="Propject1.s01.whatxaml" xmlns="http://schemas.microsoft.com/winfx/2006

 第一个Silverlight程序,绘制一个长方型、一个椭圆、画一条线

1、首先新建一个Silverlight程序,然后新建一个UserControl页面命名为whatxaml.xaml,在前台绘制图形:

<UserControl x:Class="Propject1.s01.whatxaml"    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">    <!-- 画布元素 -->    <Canvas x:name="LayoutRoot" Background="White" >        <!-- 绘制矩形元素 -->        <Rectangle WIDth="240" Height="100" Fill="Gold" stroke="Black" Canvas.top="20" Canvas.left="20" />        <!-- 绘制一个圆形元素 -->        <Ellipse WIDth="200" Height="100" Fill="BurlyWood" stroke="Black" Canvas.left="20" Canvas.top="126" />        <!--绘制一个圆形元素-->        <TextBlock Text="Silverlight开发历程" Foreground="Black" Canvas.left="28" Canvas.top="165" FontSize="20"/>        <!--绘制线条-->        <line X1="50" Y1="130" X2="260" Y2="260" stroke="Red" strokeThickness="3" />    </Canvas>    <!-- /画布元素 --></UserControl>

2、更改启动项,双击打开App.xaml 然后将Application_Startup事件下的new 实例更改为UserControl的实例名,如下代码

 public partial class App : Application    {        public App()        {            this.Startup += this.Application_Startup;            this.Exit += this.Application_Exit;            this.UnhandledException += this.Application_UnhandledException;            InitializeComponent();        }        private voID Application_Startup(object sender,StartupEventArgs e)        {            this.RootVisual = new whatxaml();        }


然后按F5运行,就看到想要的结果:


 

第一个小例子,程序很简单主要是为了体会Silverlight在绘制图形方面的强大功能。

总结

以上是内存溢出为你收集整理的第一个Silverlight程序,绘制一个长方型、一个椭圆、画一条线全部内容,希望文章能够帮你解决第一个Silverlight程序,绘制一个长方型、一个椭圆、画一条线所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1072787.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存