[Winodows Phone 7 control details] usercontrol

Source: Internet
Author: User

The Silverlight toolkit for Windows Phone 7.1 Control described earlier is essentially a user-defined control. You can define some controls as needed.

The following is a simple waitingbox with animations:

1. Create: usercontrol inherits the control class "usercontrol". That is to say, all attributes and methods of the control are available. What you need must be expanded by yourself.

XAML:

<Popup X: Name = "waitingwnd" isopen = "true"> <grid width = "300" Height = "400" background = "Transparent" X: name = "layoutroot"> <Image Height = "300" width = "300" horizontalalignment = "Left" name = "image1" stretch = "fill" verticalignment = "TOP"/> <textblock Height = "30" horizontalalignment = "Left" margin = "106,314, 0, 0 "name =" textblock1 "text =" Please wait... "verticalalignment =" TOP "/> </GRID> </popup>

Generally, the background color of the Container Control is set to transparent (background = "Transparent ")

CS:

public partial class WindowsPhoneControl1 : UserControl    {        DispatcherTimer timer = new DispatcherTimer();        int count = 0;        public double Speed { get; set; }        public WindowsPhoneControl1()        {            InitializeComponent();        }        private void UserControl_Loaded(object sender, RoutedEventArgs e)        {                       timer.Interval = TimeSpan.FromMilliseconds(Speed);            timer.Tick += new EventHandler(timer_Tick);        }        void timer_Tick(object sender, EventArgs e)        {            image1.Source = new BitmapImage(new Uri("Images/" + count + ".png", UriKind.Relative));            count=(count==7?0:count+1);        }        public void WaitingBegin()        {            if (timer == null)            {                timer = new DispatcherTimer();            }            timer.Start();            WaitingWnd.IsOpen = true;        }        public void WaitingEnd()        {            timer.Stop();            WaitingWnd.IsOpen = false;        }    }

You have extended a speed attribute and remember to set it when using it.

After compilation, you can see the defined control in the toolbar.

Use: drag and drop to set the speed attribute.

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">            <my:WindowsPhoneControl1 Speed="200" HorizontalAlignment="Left" Margin="82,96,0,0" x:Name="windowsPhoneControl11" VerticalAlignment="Top" Height="400" Width="300" />        </Grid>

Windowsphonecontrol11.waitingbegin ();//

Waitingbox1.waitingend ();

The World Wide Web is a good thing. The picture comes from the dark blue right hand. This animation was used in Silverlight game development before, so it can be used directly ~ I would also like to thank Xiao Zhen for his selfless dedication and learning and making progress together ~

 

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.