Smooth Transformation of SL review notes-basics (III. SL installation testing and background flushing with a "brush)

Source: Internet
Author: User

First of all, I would like to thank all the netizens for their support (giving the younger brother motivation, sticking to it, and doing meaningful things ,), I believe everyone will be attracted by the "SL" cool and dazzling "User Experience. With the advent of the Web 3D era, you know the rise of WP.
To create a new project, first check whether the user has installed "SL". The interaction between "SL" and the browser is inseparable from "JS ".
I. Use "JS" to check whether "SL" is installed"
1. browser compatibility should be considered first when "JS" is used. There are two types: IE and non-ie (Firefox and chrome ).
2. paste the code
<Script language = "JavaScript">
VaR browser = navigator. appname; // obtain the browser
VaR slinstalled = false; // sets the flag.
If (Browser = 'Microsoft Internet Explorer '){
Try {
VaR slcontrol = new activexobject ('agcontrol. agcontrol ');
Slinstalled = true;
} Catch (e ){
// Error. Silverlight is not installed. Please install it first.
}
} Else {
// Netscape, Firefox, Google Chrome, etc.
Try {
If (navigator. plugins ["Silverlight plug-in"]) {
Slinstalled = true;
}
} Catch (e ){
// Error. Silverlight is not installed. Please install it first.
}
}
Alert (slinstalled );
</SCRIPT>
Ii. Set the background image
1. The background of the "SL" UI element is "Flushed" instead of "background" directly like "html" and "Asp.net ". Use imagebrush ".
2. Different "UI" elements have different properties. For example, canvas is applied to "canvas. Background", and "ellipse" is applied to "ellipse. Fill ".
3. Since it is applied to the attributes of the UI element, you can use the "brush" in the background code dynamically to enjoy the "brush ".
Sample Code:
Use in XAML:
<Canvas X: Name = "showcanvas" width = "500" Height = "300">
<Canvas. Background>
<Imagebrush X: Name = "bgimagebrush" stretch = "uniformtofill"
Imagesource = "images/bg1.png">
</Imagebrush>
</Canvas. Background>
</Canvas>
Use in background code:
Imagebrush brush = new imagebrush ();
Brush. imagesource = new bitmapimage (New uri (@ "images/ball.png ",
Urikind. Relative ));
Ellipse1.fill = brush;

Latest database, transfer array

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.