Lập trình .net 4.0 và visual studio 2010 part 51

Silverlight cho phép bạn animate declaratively cả các đối tượng và lập trình. Hoạt hình có lẽ là dễ hiểu lập trình, vì vậy bạn sẽ tạo ra một hình ảnh động rất đơn giản để di chuyển một hình chữ nhật trên màn hình một và cùng một lúc thay đổi minh bạch của nó bằng cách sửa đổi opacity của nó | CHAPTER 14 SILVERLIGHT INTRODUCTION Simple Animation Silverlight allows you to animate objects both declaratively and programmatically. Animation is perhaps easier to understand programmatically so you will create a very simple animation to move a rectangle across a screen and at the same time change its transparency by modifying its opacity. You will use a Storyboard class to create an animation. The Storyboard defines what will happen within the animation the story and contains features to start stop and repeat the animation. The storyboard has a property called Interval that is a timer that allows you to perform the animation. In the example when the storyboard interval occurs you will increment the x and y position of the rectangle and increase the opacity. Creating Animation Programmatically Let s start the example 1. Create a new folder called Animation within your project. 2. Right-click this folder Add New ItemXSilverlight User Control. 3. Call it Animation. 4. Remove the d DesignHeight 300 d DesignWidth 400 properties from the user control tag. 5. Replace the Grid tags with the following XAML Canvas Width 900 Height 700 Background AliceBlue Rectangle Width 52 Height 52 Stroke FF000000 Opacity 0 Fill Red x Name rectAnimation RadiusX 10 RadiusY 10 Canvas 6. Open Animation Animation. xaml .cs and enter the following code public partial class Animation UserControl Storyboard StoryBoard new Storyboard int Count 0 public Animation new RoutedEventHandler Animation_Loaded new EventHandler StoryBoard_Completed InitializeComponent public void Animation_Loaded object sender RoutedEventArgs e 10 void StoryBoard_Completed object sender EventArgs e rectAnimation Count rectAnimation Count Count 345 CHAPTER 14 SILVERLIGHT INTRODUCTION Count 1 if Count 100 7. Now edit .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
54    329    7    29-03-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.