Monday, May 21, 2012 : Article > Windows Phone User : Register | Login
บทความ
Webboard
วีดีโอ
บทความจากเพื่อนๆ Guru
25

วันนี้เราจะมาเขียนโปรแกรมง่ายๆ นั้นก็คือ mini webbrowser

1.  สร้างโปรเจคขึ้นมาให้  ตั้งชื่อว่า Minibrowser

image

2.  เปลี่ยนชื่อข้อความที่หัวข้อ เป็น Mini Browser

image

3. ลากและจัด Tool ต่างดังภาพ

image

4.  ลบข้อความ TextBox และเปลี่ยน ชื่อ Button เป็น go

image

5.  ไปที่หน้า Code MainPage.xaml.cs 

      5.1  ตั้งค่าให้สามารถดูได้ทั้งแนวตั้งแนวนอนด้วยการเพิ่มคำสั่งใน Mainpage()

             SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape;

image

     5.2  ตั้งเมดตอดการทำงานปุ่ม Go เพื่อรับค่า Url และ ให้ webbrowser แสดงผล         

        private void GoBt_Click(object sender, RoutedEventArgs e)

        {
            string site;

            site = textBox1.Text;
            try // ถ้ามีการใส่ Potocal http
            {
                webBrowser1.Navigate(new Uri(site, UriKind.Absolute));
            }
            catch // ถ้าไม่ใส่ Potocal http
            {
                site = "http://" + site; // เพิ่ม Potocal
                webBrowser1.Navigate(new Uri(site, UriKind.Absolute));
            }
        }

6.  ทำให้ปุ่ม Go รู้จักเมดอตอดที่สร้างด้วยการเพิ่ม event   click = "GoBt_Click"  ใน tag button

 

image

7.  ทดสอบรันโปรแกรม

imageimage

Post Rating

Comments

There are currently no comments, be the first to post one.

Post Comment

Only registered users may post comments.
Home | Article | Webboard | Video | Blog | Showcase | News
Copyright 2010 by devguru.mobi