I have the following code:
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
And I’m implementing this later on:
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
However, I get an error saying:
‘SaveCulture’ is not a member of ‘System.Windows.Application’
‘Refresh’ is not a member of ‘System.Windows.Application’
‘SaveCulture’ is not a member of ‘System.Windows.Application’
Can someone help me out with this?
Now I should mention that I have a C# version of this and that has no problems.
Thanks, y’all.
You are not following VB.NET extension method rules. Which dictates that:
<Extension>attributeImportsstatement for the module.And VS2010 or higher is required. The MSDN Library article is here.