วันเสาร์ที่ 5 พฤษภาคม พ.ศ. 2555

Silverlight Check Out of browser(C Sharp)

โค้ดสำหรับการเช็คว่า มีการรัน Application Out of browser รันอยู่รึเปล่า

            if (Application.Current.IsRunningOutOfBrowser)
            {
                btn_install.IsEnabled = false;
                btn_update.IsEnabled = true;
            }
            else
            {
                btn_install.IsEnabled = true;
                btn_update.IsEnabled = false  ;
            }
จะเป็นการเช็คว่า มีการรันอยู่รึเปล่าต่อไปก็เช็คให้มีการอัพเดตใหม่
 
//download update out of browser
Application.Current.CheckAndDownloadUpdateAsync();
Application.Current.CheckAndDownloadUpdateCompleted += new CheckAndDownloadUpdateCompletedEventHandler(Current_CheckAndDownloadUpdateCompleted);
void Current_CheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e)
        {
            if (e.UpdateAvailable) MessageBox.Show("Update complete");
        }