2
我有以下代碼:擴展system.windows.application不承認
Private Sub LocalizationComboBox_SelectionChanged(sender As Object, e As SelectionChangedEventArgs)
Thread.CurrentThread.CurrentUICulture = TryCast(e.AddedItems(0), CultureInfo)
Application.Current.SaveCulture()
Application.Current.Refresh()
End Sub
而且我後來實現這個:
Public NotInheritable Class ApplicationExtensions
Public Shared Sub Refresh(app As Application)
DirectCast(HtmlPage.Window.GetProperty("location"), ScriptObject).Invoke("reload")
End Sub
Public NotInheritable Class ApplicationExtensions
Private Sub New()
End Sub
Public Shared Sub Refresh(app As Application)
DirectCast(HtmlPage.Window.GetProperty("location"), ScriptObject).Invoke("reload")
End Sub
Public Shared Sub LoadCulture(app As Application)
Try
If IsolatedStorageSettings.ApplicationSettings.Contains("language") Then
Dim language = TryCast(IsolatedStorageSettings.ApplicationSettings("language"), String)
If language IsNot Nothing Then
Thread.CurrentThread.CurrentUICulture = New CultureInfo(language)
End If
Else
app.SaveCulture()
End If
Catch
MessageBox.Show("Please, open Silverlight settings and enable Application Storage.")
End Try
End Sub
Public Shared Sub SaveCulture(app As Application)
Try
IsolatedStorageSettings.ApplicationSettings("language") = Thread.CurrentThread.CurrentUICulture.Name
Catch
MessageBox.Show("Please, open Silverlight settings and enable Application Storage.")
End Try
End Sub
End Class
不過,我得到一個錯誤說:
'SaveCulture'不是'System.Windows.Application'的成員 'Refresh'不是'System.Windows.Application'的成員 'SaveCulture'不是'System.Windows.Application'的成員
有人可以幫我解決這個問題嗎? 現在我應該提一下,我有這個C#版本,這沒有問題。
謝謝,你們都。