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