Assalamu’alaikum wr. wb
Bertemu kembali dengan saya gan, kali ini kita bertemu dalam sebuah pembahasan tutorial windows phone yaitu Navigation Page. oke, langsung saja kita ke TKP
1. New Project (ctrl+shift+N)
2. Pilih windows Phone App + Visual C#
3. Beri nama project “NavigationPage” Name
project jangan lupa samakan dengan Solution Name
4. Lalu browse dan pilih dimana kita akan
menyimpan Folder Project aplikasi yang akan kita buat.
5. Lalu klik OK dan pilih Windows OS 7.1
lalu klik OK
Buat Folder untuk menyimpan halaman baru yg akan kita buat > Klik kanan pada Project– Add- New Folder (Views)
Buat 5 halaman baru > Klik kanan pada Folder Views – Add - New Item
MainPage (default)
SecondPage
ThirdPage
FourthPage
FifthPage
Elemen yang di gunakan di MainPage :
TextBox
Name="mainTBx"
Text=""
TextBlock
Name="mainTBl"
Text=""
Button1
Name="page2"
Content="SecondPage"
Button2
Name="page3"
Content="ThirdPage”
Button3
Name="page4"
Content="FourthPage”
Button4
Name="page5"
Content="FifthPage”
MainPage.xaml.cs :
// mengirimkan data di textbox ke halaman Uri
private void page2_Click(object sender, RoutedEventArgs e)
{
string name = mainTBx.Text;
NavigationService.Navigate(new Uri("/Views/SecondPage.xaml?name=" + name, UriKind.Relative));
}
// menerima data yang dikirimkan,dan format a seperti apa
protected override voidOnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
string name = "";
if (NavigationContext.QueryString.TryGetValue("name", outname))
{
mainTBl.Text = string.Format("{0}", name);
}
}
private void page3_Click(object sender, RoutedEventArgs e)
{
string name = mainTBx.Text;
NavigationService.Navigate(new Uri("/Views/ThirdPage.xaml?name=" + name, UriKind.Relative));
}
private void page4_Click(object sender, RoutedEventArgs e)
{
string name = mainTBx.Text;
NavigationService.Navigate(new Uri("/Views/FourthPage.xaml?name=" + name, UriKind.Relative));
}
private void page5_Click(object sender, RoutedEventArgs e)
{
string name = mainTBx.Text;
NavigationService.Navigate(new Uri("/Views/FifthPage.xaml?name=" + name, UriKind.Relative));
}
Elemen yang di gunakan di SecondPage :
TextBox
Name="secondTBx"
Text=""
TextBlock
Name="secondTBl"
Text=""
Button1
Name="mainpage"
Content="MainPage"
Button2
Name="page3"
Content="ThirdPage”
Button3
Name="page4"
Content="FourthPage”
Button4
Name="page5"
Content="FifthPage”
SecondPage.xaml.cs :
protected override voidOnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
string name = "";
if (NavigationContext.QueryString.TryGetValue("name", outname))
{
secondTBl.Text = string.Format("{0}", name);
}
}
private void mainpage_Click(object sender, RoutedEventArgs e)
{
string name = secondTBx.Text;
NavigationService.Navigate(new Uri("/MainPage.xaml?name=" + name, UriKind.Relative));
}
private void page3_Click(object sender, RoutedEventArgs e)
{
string name = secondTBx.Text;
NavigationService.Navigate(new Uri("/Views/ThirdPage.xaml?name=" + name, UriKind.Relative));
}
private void page4_Click(object sender, RoutedEventArgs e)
{
string name = secondTBx.Text;
NavigationService.Navigate(new Uri("/Views/FourthPage.xaml?name=" + name, UriKind.Relative));
}
private void page5_Click(object sender, RoutedEventArgs e)
{
string name = secondTBx.Text;
NavigationService.Navigate(new Uri("/Views/FifthPage.xaml?name=" + name, UriKind.Relative));
}
Elemen yang di gunakan di ThirdPage :
TextBox
Name="thirdTBx"
Text=""
TextBlock
Name="thirdTBl"
Text=""
Button1
Name="mainpage"
Content="MainPage"
Button2
Name="page2"
Content="SecondPage”
Button3
Name="page4"
Content="FourthPage”
Button4
Name="page5"
Content="FifthPage”
ThirdPage.xaml.cs :
protected override voidOnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
string name = "";
if (NavigationContext.QueryString.TryGetValue("name", outname))
{
thirdTBl.Text = string.Format("{0}", name);
}
}
private void mainpage_Click(object sender, RoutedEventArgs e)
{
string name = thirdTBx.Text;
NavigationService.Navigate(new Uri("/MainPage.xaml?name=" + name, UriKind.Relative));
}
private void page2_Click(object sender, RoutedEventArgs e)
{
string name = thirdTBx.Text;
NavigationService.Navigate(new Uri("/Views/SecondPage.xaml?name=" + name, UriKind.Relative));
}
private void page4_Click(object sender, RoutedEventArgs e)
{
string name = thirdTBx.Text;
NavigationService.Navigate(new Uri("/Views/FourthPage.xaml?name=" + name, UriKind.Relative));
}
private void page5_Click(object sender, RoutedEventArgs e)
{
string name = thirdTBx.Text;
NavigationService.Navigate(new Uri("/Views/FifthPage.xaml?name=" + name, UriKind.Relative));
}
Elemen yang di gunakan di FourthPage :
TextBox
Name="fourthTBx"
Text=""
TextBlock
Name="fourthTBl"
Text=""
Button1
Name="mainpage"
Content="MainPage"
Button2
Name="page3"
Content="ThirdPage”
Button3
Name="page4"
Content="FourthPage”
Button4
Name="page5"
Content="FifthPage”
FourthPage.xaml.cs :
protected override voidOnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
string name = "";
if (NavigationContext.QueryString.TryGetValue("name", outname))
{
fourthTBl.Text = string.Format("{0}", name);
}
}
private void mainpage_Click(object sender, RoutedEventArgs e)
{
string name = fourthTBx.Text;
NavigationService.Navigate(new Uri("/MainPage.xaml?name=" + name, UriKind.Relative));
}
private void page2_Click(object sender, RoutedEventArgs e)
{
string name = fourthTBx.Text;
NavigationService.Navigate(new Uri("/Views/SecondPage.xaml?name=" + name, UriKind.Relative));
}
private void page3_Click(object sender, RoutedEventArgs e)
{
string name = fourthTBx.Text;
NavigationService.Navigate(new Uri("/Views/ThirdPage.xaml?name=" + name, UriKind.Relative));
}
private void page5_Click(object sender, RoutedEventArgs e)
{
string name = fourthTBx.Text;
NavigationService.Navigate(new Uri("/Views/FifthPage.xaml?name=" + name, UriKind.Relative));
}
Elemen yang di gunakan di FifthPage :
TextBox
Name="fifthTBx"
Text=""
TextBlock
Name="fifthTBl"
Text=""
Button1
Name="mainpage"
Content="MainPage"
Button2
Name="page2"
Content="SecondPage”
Button3
Name="page3"
Content="ThirdPage"
Button4
Name="page4"
Content="FourthPage"
FifthPage.xaml.cs :
protected override voidOnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
string name = "";
if (NavigationContext.QueryString.TryGetValue("name", outname))
{
fifthTBl.Text = string.Format("{0}", name);
}
}
private void mainpage_Click(object sender, RoutedEventArgs e)
{
string name = fifthTBx.Text;
NavigationService.Navigate(new Uri("/MainPage.xaml?name=" + name, UriKind.Relative));
}
private void page2_Click(object sender, RoutedEventArgs e)
{
string name = fifthTBx.Text;
NavigationService.Navigate(new Uri("/Views/SecondPage.xaml?name=" + name, UriKind.Relative));
}
private void page3_Click(object sender, RoutedEventArgs e)
{
string name = fifthTBx.Text;
NavigationService.Navigate(new Uri("/Views/ThirdPage.xaml?name=" + name, UriKind.Relative));
}
private void page4_Click(object sender, RoutedEventArgs e)
{
string name = fifthTBx.Text;
NavigationService.Navigate(new Uri("/Views/FourthPage.xaml?name=" + name, UriKind.Relative));
}
Mungkin cukup sekian sedikit tutorial dari saya, semoga bermanfaat bagi agan-agan sekalian, mohon maaf apabila ada salah-salah kata, atau banyak kekurangan pada tutorial ini, karena kesempurnaan hanya milik Allah SWT.
sampai bertemu pada sesi-sesi tutorial lainnya
Wassalamu’alaikum wr.wb
0 komentar:
Posting Komentar