Danh mục

Essential Silverlight 3- P4

Số trang: 50      Loại file: pdf      Dung lượng: 400.87 KB      Lượt xem: 20      Lượt tải: 0    
tailieu_vip

Hỗ trợ phí lưu trữ khi tải xuống: 2,000 VND Tải xuống file đầy đủ (50 trang) 0
Xem trước 5 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Essential Silverlight 3- P4: Khái quát Silverlight 3 không chỉ là lấp đầy với các chi tiết kỹ thuật, ví dụ rõ ràng, và thực hiện lời khuyên rằng sẽ làm cho bất kỳ ứng dụng Silverlight tốt hơn, nhưng Ashraf cũng bao gồm những hiểu biết rằng chỉ có thể đến từ một trong những nhà phát triển dẫn của thời gian chạy Silverlight. Từ đồ họa, văn bản, để phương tiện truyền thông cuốn sách này- có tất cả các thông tin cần thiết về thời gian chạy lõi 3 Silverlight....
Nội dung trích xuất từ tài liệu:
Essential Silverlight 3- P4 118 Chapter 5: Input Events Multiple Languages Different operating system language settings can have different keyboard mappings or language specific input methods for Far East languages. To help you create applications that work on multiple languages, Silverlight provides a TextBox element that provides text input for European and Far East languages. In particular, you can use the Far East input method editors or operating system mechanisms for inputting European accents with the TextBox element. For custom controls that require direct access to keyboard events, Silverlight filters the basic key codes in the System.Windows.Input.Key enumeration to only those available consistently in all supported languages. In particular, keys such as the comma key are different in different languages and do not appear in the Key enumeration. For example, many European languages use a comma to indicate a decimal separator in a number instead of a period. You can still access those keys not in the Key enumeration by specifying their key code number; however, you must test those events on all target languages. Input Events As discussed in Chapter 2, “Applications,” you can connect an event handler to code by setting the event handler in XAML: Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Input Events 119 You can define this event handler in your C# code behind class: namespace RectangleClick { public partial class Page : UserControl { private void MyRectangle_MouseLeftButtonDown( object sender, MouseButtonEventA rgs e ) { Rectangle myRectangle = (Rectangle)sender; myRectangle.Fill = new SolidColorBrush(Colors.Blue); } } } Alternatively, you can connect an event handler programmatically in your constructor: namespace RectangleClick { public partial class Page : UserControl { public Page() { InitializeComponent(); // Hook up left mouse button down event Rectangle myRectangle = (Rectangle)this.FindName(myRectangle); myRectangle.MouseLeftButtonDown += new MouseButtonEventHandler(MyRectangle_MouseLeftButtonDown); } } } New in Silverlight 3 You can use mouse wheel events in Silverlight 3 by setting the MouseWheel event handler. Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 120 Chapter 5: Input Events Mouse Input Events Connecting mouse events to handlers is straightforward, as shown in the previous examples. However, Silverlight must decide which element should receive a particular event. This section discusses the three aspects that determine which element gets the event: mouse capture, bubbling, and hit-testing rules. Mouse Capture As previously shown, you can connect a MouseLeftButtonDown event handler to an element to receive that event. Similarly, a MouseLeftButtonUp event is available. In some cases, you may not receive a MouseLeftButtonUp event after a MouseLeftButtonDown event. For example, if a user depresses the mouse but- ton over an element, moves the mouse, and then releases the mouse button, the mouse may no longer be over the target element and Silverlight does not send the MouseLeftButtonUp event to your event handler. If you want to guarantee a MouseLeftButtonUp event, you can take mouse capture while the mouse button is down and release it when the mouse button is up. For example, to have a simple rectangle change color on mouse down and restore color on mouse up, you can connect your event handlers in your page constructor and toggle properties to change the rectangle color: namespace RectangleClick { public partial class Page : UserControl { public Page() { InitializeComponent(); // Hook up event handlers for the rectangle Rectangle myRectangle = (Rectangle)this.FindName(myRectangle); myRectangle.MouseLeftButtonDown += new MouseButtonEventHandler(MyRectangle_MouseLeftButtonDown); myRectangle.MouseLeftButtonUp += new MouseButtonEventHandler(MyRectangle_MouseLeftButtonUp); } private void MyRectangle_MouseLeftButtonDown( object sender, Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Input Events 121 MouseButtonEventA rgs e ) { ...

Tài liệu được xem nhiều: