The smooth transformation of SL review notes-basics (4. Multimedia, tooltip, and right-click menu)

Source: Internet
Author: User

I. Multimedia

1. SL supports multimedia using the "mediaelement" class.

2. Set the file to "embedded resources ".

3. Define the mediaelement object in XAML.

Small instance

Mediaelement media = new mediaelement ();
Stream stream = assembly. getexecutingassembly (). getmanifestresourcestream (
"Myslpro.love1.wav"); // capture the video stream from the application assembly

Media. setsource (Stream); // sets the media source.

Media. autoplay = false; // playback control
Media. Stop ();
Media. Play ();

2. Add a tooltip

1. Use the "tooltipservice" control to act on other controls, such as buttons, Textbox, and panel ).

2. usage. In XAML, place it between two labels ". In the background code, declare the object for dynamic settings.

Instance:

<Textbox width = "50" Height = "40" text = "You guess">
<Tooltipservice. tooltip>
<Image Source = "/images/gile.jpg">
</Image>
</Tooltipservice. tooltip>
</Textbox>

Background code:

Tooltipservice. settooltip (bt_test, "click ");

3. Right-click the menu

In SL, You can intercept the default context menu of SL and display the custom menu as follows:

1. Set the "windowless" attribute to "true" on the web page for loading SL ".

2. On the XAML page, set the "attachevent" attribute of the browser document object and add the required event operations to the "oncontextmenu" event. Of course, you can also add events to the background method of APP. XAML so that users can perform their own operations on any XAML page.

Brief example:

System. Windows. browser. htmlpage. Document. attachevent ("oncontextmenu", this. oncontextmenu );

Private void oncontextmenu (Object sender, system. Windows. browser. htmleventargs E)

{
MessageBox. Show ("You are clicking" + E. offsetx + "," + E. offsety );
E. preventdefault ();
}

Next, write data binding. I have been writing for more than an hour, so I have to work on the project.

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.