当按下按钮时,是否可以在运行时刷新wpf页面?

时间:2019-06-10 16:25:51

标签: vb.net visual-studio

我有一个带有选项列表的DataGrid。我创建了一个在法语和英语之间切换的按钮(效果很好),但是如果在显示带有DataGrid的表单时按下按钮,则选项不会更改语言。但是,如果我退出该页面并重新打开它,则会以所选语言显示选项。我需要一种模拟页面的关闭和打开或刷新的方法,以使其正常工作。有什么想法吗?

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"
                subLoadReportList()


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

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

Private Sub subLoadReportList()
        Try
            If gCurrentStrLanguage Is Nothing OrElse gCurrentStrLanguage = "EN" Then
                dgDefinedReport.ItemsSource = ActiveReports
                dgDefinedReport.DisplayMemberPath = "Name_English"
                dgDefinedReport.SelectedValuePath = "Defined_Report_ID"
            Else
                dgDefinedReport.ItemsSource = ActiveReports
                dgDefinedReport.DisplayMemberPath = "Name_French"
                dgDefinedReport.SelectedValuePath = "Defined_Report_ID"
            End If

            dgDefinedReport.ItemsSource = ActiveReports
            dgDefinedReport.ItemsSource = AllowedReports    ' 26 Aug 2014 DBE - Add security to this screen
            dgDefinedReport.DisplayMemberPath = "Report_Name"
            dgDefinedReport.SelectedValuePath = "Defined_Report_ID"

        Catch ex As Exception
            strError = ex.Message & vbCrLf & " IN: " & Me.GetType.FullName
            Throw New LegalServicesException(ex)
        Finally
            If strError.Length() > 0 Then
                modGlobalFunctions.DisplayErrorMsg(strError, strError)
                strError = String.Empty
            End If
        End Try
    End Sub

我目前没有“刷新”按钮。单击btnChangeLanguage之后,我将需要刷新页面。

0 个答案:

没有答案