有没有一种方法可以从子视图更新视图?

时间:2019-06-21 16:55:03

标签: vb.net visual-studio

我有一个带有多个屏幕的wpf应用程序。我有一个按钮可以将屏幕从法语翻译为英语,然后再翻译回英语,这在当前页面上可以正常使用。但是,当我在应用程序中打开子菜单并更改语言时,上一个屏幕的某些元素不会更新。

我尝试创建主屏幕的实例并从子菜单执行方法,但是,此操作无法正常运行。我的猜测是,由于我创建的实例与主菜单不是同一对象,因此它对主菜单没有任何作用。

在名为wpfFileNumSearch的子菜单中(子菜单):

Private Sub btnChangeLanguage_Click(sender As Object, e As RoutedEventArgs) Handles btnChangeLanguage.Click
        Try
            If CurrentLanguageSelection = enumLanguage.English Then
                CurrentLanguageSelection = enumLanguage.French
                Dim newCulture As CultureInfo = New CultureInfo("fr-CA")
                Thread.CurrentThread.CurrentCulture = newCulture
                gCurrentStrLanguage = "FR"

            ElseIf CurrentLanguageSelection = enumLanguage.French Then
                CurrentLanguageSelection = enumLanguage.English
                Dim newCulture As CultureInfo = New CultureInfo("en-CA")
                Thread.CurrentThread.CurrentCulture = newCulture
                gCurrentStrLanguage = "EN"

            End If
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

在主菜单(wpfTimeEntryList)中,当单击子菜单中的更改语言按钮时,我需要更新comboBoxes。我在主菜单中有执行此操作的方法:

Public Sub subLoadComboActivityToFrench()
        comboActivity.ItemsSource = ActiveDefinedActivities    'ls.dtActivity
        comboActivity.DisplayMemberPath = "Description_French"
        comboActivity.SelectedValuePath = "Defined_Activity_ID"

        comboFunction.ItemsSource = ActiveDefinedFunctions    'ls.dtFunction
        comboFunction.DisplayMemberPath = "Description_French"
        comboFunction.SelectedValuePath = "Defined_Function_ID"
    End Sub

    Public Sub subLoadComboActivityToEnglish()
        comboActivity.ItemsSource = ActiveDefinedActivities    'ls.dtActivity
        comboActivity.DisplayMemberPath = "Description_English"
        comboActivity.SelectedValuePath = "Defined_Activity_ID"

        comboFunction.ItemsSource = ActiveDefinedFunctions    'ls.dtFunction
        comboFunction.DisplayMemberPath = "Description_English"
        comboFunction.SelectedValuePath = "Defined_Function_ID"
    End Sub

有什么方法可以从子菜单中更新主菜单吗?

0 个答案:

没有答案