silverlight   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了第一个Silverlight程序,绘制一个长方型、一个椭圆、画一条线大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

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

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

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

<UserControl x:Class="Propject1.s01.whatxaml"
    xmlns="http://scheR_493_11845@as.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://scheR_493_11845@as.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://scheR_493_11845@as.microsoft.com/expression/blend/2008"
    xmlns:mc="http://scheR_493_11845@as.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程序,绘制一个长方型、一个椭圆、画一条线全部内容,希望文章能够帮你解决第一个Silverlight程序,绘制一个长方型、一个椭圆、画一条线所遇到的程序开发问题。

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

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。