WPF和Silverlight概述(1)

WPF和Silverlight概述(1),第1张

概述WPF(Windows Presentation Foundation,Windows外观基础(直译))是基于Framework 3.0(含以后版本)的新一代Windows界面开发技术。   Silverlight(中文翻译为“银光”),可以看成是WPF的Web应用产品,其早先名为WPF/E。其主要应用于Web富客户端应用程序(RIA,Rich Interface Application)。现阶段

WPF(windows Presentation Foundation,windows外观基础(直译))是基于Framework 3.0(含以后版本)的新一代windows界面开发技术。

  Silverlight(中文翻译为“银光”),可以看成是WPF的Web应用产品,其早先名为WPF/E。其主要应用于Web富客户端应用程序(RIA,Rich Interface Application)。现阶段此技术可以说比较“火”,微软在此方面主要的对手就是Adobe公司的以Flash为基础的Flex技术。  两者均是以XAML为基础的,在某些条件下是可以相互的转换:如定义一个简单的ARGB调色版应用:WPF应用程序如下: XAML文件:

<Window x:Class="WPFcolorVersion.MainWindow"    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    title="WPF color Version" Height="300" WIDth="400" windowstartupLocation="CenterScreen" ResizeMode="noresize">    <Canvas margin="0,0">        <Canvas.Background>            <linearGradIEntBrush EndPoint="0.5,1" StartPoint="0.5,255)">                <GradIEntStop color="#FF6254E2" Offset="0.996"/>                <GradIEntStop color="#FFFFFFFF" Offset="0"/>            </linearGradIEntBrush>        </Canvas.Background>        <TextBlock Height="34" Canvas.left="28" Canvas.top="17" Text="WPF color Version" textwrapPing="Wrap" FontSize="24"             FontFamily="Comic Sans MS" FontWeight="Bold"/>        <TextBlock Height="34" Canvas.left="22" Canvas.top="38" FontFamily="Comic Sans MS" FontSize="24" FontWeight="Bold"             Text="WPF color Version" textwrapPing="Wrap" RendertransformOrigin="0.5,0.5">            <TextBlock.Foreground>                <linearGradIEntBrush EndPoint="0.5,255)">                    <GradIEntStop color="#FF000000" Offset="1"/>                    <GradIEntStop color="#FFD9DFF0" Offset="0.026"/>                    <GradIEntStop color="#FF7D818B" Offset="0.78"/>                </linearGradIEntBrush>            </TextBlock.Foreground>            <TextBlock.Rendertransform>                <transformGroup>                    <Scaletransform ScaleX="1" ScaleY="-1"/>                    <Skewtransform AngleX="-29" AngleY="0"/>                    <Rotatetransform Angle="0"/>                    <Translatetransform X="0" Y="0"/>                </transformGroup>            </TextBlock.Rendertransform>        </TextBlock>        <Rectangle Fill="#00000000" WIDth="156" Height="103" Canvas.left="219" Canvas.top="108" x:name="demoArea" />        <TextBlock WIDth="15" Height="17" Canvas.top="116" Text="A" textwrapPing="Wrap" Canvas.left="28" HorizontalAlignment="Center"/>        <TextBlock WIDth="15" Height="17" Canvas.left="28" Canvas.top="142" Text="R" textwrapPing="Wrap" HorizontalAlignment="Center"/>        <TextBlock WIDth="15" Height="17" Canvas.left="28" Canvas.top="166" Text="G" textwrapPing="Wrap" HorizontalAlignment="Center"/>        <TextBlock WIDth="15" Height="17" Canvas.left="28" Canvas.top="194" Text="B" textwrapPing="Wrap" HorizontalAlignment="Center"/>        <SlIDer WIDth="148" Height="22" Canvas.left="43" Canvas.top="111" Maximum="255" x:name="slIDerA" ValueChanged="slIDerValueChanged"/>        <SlIDer WIDth="148" Height="22" Canvas.left="43" Canvas.top="137" Maximum="255" x:name="slIDerR" ValueChanged="slIDerValueChanged"/>        <SlIDer WIDth="148" Height="22" Canvas.left="43" Canvas.top="163" Maximum="255" x:name="slIDerG" ValueChanged="slIDerValueChanged"/>        <SlIDer WIDth="148" Height="22" Canvas.left="43" Canvas.top="189" Maximum="255" x:name="slIDerB" ValueChanged="slIDerValueChanged"/>        <TextBlock WIDth="75" Height="17" Canvas.left="143" Canvas.top="230" Text="color Value:"/>        <TextBox WIDth="89" Height="20" Canvas.left="219" Canvas.top="227" Text="#00000000" x:name="txtcolorValue"/>    </Canvas></Window>代码文件:using System.windows;using System.windows.Media;namespace WPFcolorVersion{    /// <summary>    /// Interaction logic for MainWindow.xaml    /// </summary>    public partial class MainWindow : Window    {        public MainWindow()        {            InitializeComponent();        }        private voID slIDerValueChanged(object sender, System.windows.RoutedPropertyChangedEventArgs<double> e)            byte a = (byte)(slIDerA.Value);            byte r = (byte)(slIDerR.Value);            byte g = (byte)(slIDerG.Value);            byte b = (byte)(slIDerB.Value);            color clr = color.FromArgb(a, r, g, b);            demoArea.Fill = new SolIDcolorBrush(clr);            txtcolorValue.Text = clr.ToString();而对应在Silverlight中,XAML文件内:<UserControl x:Class="SilverlightcolorVersion.MainPage"    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     WIDth="400" Height="300">    <!--此位置与WPF项目的XAML文件内容完全相同--></UserControl>另外,Silverlight的代码文件内容也与WPF项目中的代码相同。WPF应用程序执行的结果如下:

 

 

在firefox(3.0.8)及IE(8.0)中执行Silverlight项目的结果如下:

 

从此可以看出,WPF与Silverlight有着千丝万缕的联系,我们在学习过程中可以相互的对比。本文来自:http://hzyup.blog.163.com/blog/static/103326012009101311458459/

总结

以上是内存溢出为你收集整理的WPF和Silverlight概述(1)全部内容,希望文章能够帮你解决WPF和Silverlight概述(1)所遇到的程序开发问题。

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

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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存