zoukankan      html  css  js  c++  java
  • Pro Silverlight 3 in C# Introducing Silverlight

    1.Creating a Stand-Alone Silverlight Project

    2.Creating a Simple Silverlight Page

    <UserControl x:Class="SilverlightApplication1.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:DesignWidth="300" d:DesignHeight="400">
    <Grid x:Name="LayoutRoot" Background="White">
    <StackPanel>
    <TextBlock x:Name="lblMessage" Text="Hello world."
    Margin="5"></TextBlock>
    <Button x:Name="cmdClickMe" Content="Click Me!" Margin="5"></Button>
    </StackPanel></Grid>
    </UserControl>

    3. Adding Event Handling Code

    <Button x:Name="cmdClickMe" Click="cmdClickMe_Click" Content="Click Me!"
    Margin="5"></Button>
    private void cmdClickMe_Click(object sender, RoutedEventArgs e)
    {
    lblMessage.Text = "Goodbye, cruel world.";
    }

    3.1 You can also connect an event with code. The place to do it is the constructor for your
    page, after the call to InitializeComponent(), which initializes all your controls. Here’s the code
    equivalent of the XAML markup shown previously:

    public MainPage()
    {
    InitializeComponent();
    cmdClickMe.Click += cmdClickMe_Click;
    }

    3.2 If you want to detach an event handler, code is your only option. You can use the -=
    operator, as shown here:

    cmdClickMe.Click -= cmdClickMe_Click;

    4.The HTML Entry Page

    <html xmlns="http://www.w3.org/1999/xhtml">
    <!-- saved from url=(0014)about:internet -->
    <head>
    <title>SilverlightApplication1</title>
    <style type="text/css">
    ...
    </style>
    <script type="text/javascript">
    ...
    </script>
    </head>
    <body>
    <form id="form1" runat="server" style="height:100%">
    <!-- Silverlight content will be displayed here. -->
    <div id="silverlightControlHost">
    <object data="data:application/x-silverlight-2,"
    type="application/x-silverlight-2" width="100%" height="100%">
    <param name="source" value="SilverlightApplication1.xap" />
    <param name="onError" value="onSilverlightError" />
    <param name="background" value="white" />
    <param name="minRuntimeVersion" value="3.0.40624.0" />
    <param name="autoUpgrade" value="true" />
    <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0"
    style="text-decoration:none"><img src="http://go.microsoft.com/fwlink/?LinkId=108181"
    alt="Get Microsoft Silverlight" style="border-style:none"/>
    </a>
    </object>
    <iframe id="_sl_historyFrame"
    style="visibility:hidden;height:0px;0px;border:0px"></iframe>
    </div>
    </body>
    </html>

    4.1 Silverlight Parameters

    source,onError,background,minRuntimeVersion,autoUpgrade,enableHtmlAccess,

    initParams,splashScreenSource,windowless,onSourceDownloadProgressChanged,

    onSourceDownloadComplete,onLoad,onResize

    function onSilverlightError(sender, args) {
    if (args.ErrorCode == 8001)
    {
    // Find the Silverlight content region.
    var hostContainer = document.getElementById("silverlightControlHost");
    // Change the content. You can supply any HTML here.
    hostContainer.innerHTML = "...";
    }
    // (Deal with other types of errors here.)
    }
     

    Book Mark:page 71~~

  • 相关阅读:
    RCP二级菜单的实现
    volatile 的作用
    C6678 核间通信(IPC)
    大小端模式详解
    SPI 极性与相位对采样的影响
    DSP c6678的启动方式
    DSP CCS初学
    volatile的作用
    JTree/DefaultMutableTreeNode 树形结构
    java.awt.Graphics2D绘制流程图基本元素
  • 原文地址:https://www.cnblogs.com/zhanxp/p/1709389.html
Copyright © 2011-2022 走看看