Basics

Learn all the basics of windows 8 app here

1.DISPLAY A MESSAGE BOX IN APP

using reqiured: Windows.UI.Popups
Code:(to be writen in  page-name.xaml.cs)
async private void Button_Click_1(object sender, RoutedEventArgs e)//Event handler for a button click
 {
 MessageDialog md = new MessageDialog("Password Entered by User : ");
 await md.ShowAsync();
 }

2.NAVIGATING TO DIFFERENT PAGE

No using required
Code:  Frame.Navigate(typeof()); or this.Frame.Navigate(typeof(PageName));
Example if page name is SecondPage.xaml
then the code will be Frame.Navigate(typeof(SecondPage));

3.MediaElement Controls

using: Windows.UI.Xaml.Media
Example if Name of the MediaElement is 'mediaelement'
Then to control play and pause use the following codes in xaml.cs page
mediaelement.Play();
mediaelement.Pause();
mediaelement.Stop();
mediaelement.Volume = 75;

4.Removing and adding UI element dynamically

To add an ui element create it for example the following. Code illustrates the procedure.
For example i want to add a button dynamically so the code:
Button myButton = new Button(); //myButton is user defined button name
myButton.Height = 100;
myButton.Width = 100;
myButton.Content = "Hello";
rootpage.Children.Add(myButton);//rootpage is the name of the grid in which you want to add the button
In the same way rootpage.Children.Remove(myButton); will remove the UI element from the grid

Leave a comment