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~~

  • 相关阅读:
    报错:Message is larger than modules
    报错:常量字符串过长
    C#监控WinCE手机用户操作的程序,并通过usb连接发送到pc监听服务
    .Net Compact Framework coredll.dll API列表
    Oracle任意日期得到该周第一天的日期
    ORACLE查看锁表进程及杀死进程的语句
    客户端js与服务端通过BASE64进行交互
    为什么在powerdesigner成功将表生成到oracle,用sql操作提示表或视图不存在
    gprof的简单实用
    学习笔记fputs与printf
  • 原文地址:https://www.cnblogs.com/zhanxp/p/1709389.html
Copyright © 2011-2022 走看看