Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Silverlight

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you how to use Silverlight, I hope you will get something after reading this article. Let's discuss it together.

What we need now is a HTML control under non-OOB, and there is no need to set windowsless equal to true to support Chinese input.

All right, let's get started: last year, in the dark blue right-handed group, a buddy named "Superman" said DIV, and Silverlihgt was shown as a plug-in in html. We can create a DIV in html that overrides the Silverlight. So we can enter Chinese. Today we do it in the same way here.

The following code was decompiled from somewhere last year and then slightly modified. I forgot exactly where. Let's briefly analyze the code:

Let's first define the Uri property and specify the html that displays a Uri

/ set the dependency attribute of Uri, and define the event SourceUriChanged / public static readonly DependencyProperty SourceUriProperty = DependencyProperty.Register when Uri changes ("SourceUri", typeof (Uri), typeof (HTMLControl), new PropertyMetadata (null, new PropertyChangedCallback (HTMLControl.SourceUriChanged); / specify Uri / public Uri SourceUri {get {return (Uri) base.GetValue (SourceUriProperty) displayed } set {base.SetValue (SourceUriProperty, value);}}

Here are the events that are triggered when the Uri changes. The general principle is as follows:

1. Get the page to which Sl belongs and add a Div element to the page

two。 Adjust the position, length, width and height of the Div element. Make it right in the position of the Sl control

3.Refresh method mainly adjusts position, length, width and height.

Private static void SourceUriChanged (DependencyObject sender, DependencyPropertyChangedEventArgs e) {((HTMLControl) sender) .ReloadUri ();} private void ReloadUri () {if (! HtmlPage.IsEnabled) {return;} if (! this.isLoad) {return } if (this.div.Children.Count > 0) {while (div.Children.Count > 0) {this.div.RemoveChild ((HtmlElement) this.div.Children [0]) }} if (this.SourceUri = = null) {/ / directly set SourceHtml without setting Uri this.div.SetStyleAttribute ("overflow", "auto"); this.SetDivHtml (this.div, this.SourceHtml) / / refresh Html here and create Div this.Refresh ();} else {/ / set this.div.SetStyleAttribute ("overflow", "hidden") through URL; this.div.AppendChild (this.IFrame) This.IFrame.SetAttribute ("src", this.SourceUri.ToString ()); / / refresh Html this.Refresh () here;}}

The above controls can only be used in non-OOB mode, because objects such as Div,HtmlPage cannot be created in OOB mode and will also report an error (an aside: I don't understand why the HtmlPage object is used in the default SL project App.xaml.cs). So when OOB is running, friends can use MS's WebBrowser control.

After reading this article, I believe you have a certain understanding of "how to use Silverlight". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report