Truth of the matter is for what you are saying you need to do you can achieve this by not exiting the Revit API context and recreating the window. You should close not hide the window and then loop back to the point of window creation in order to remain in the context. After recreating your window you can rebind it to your updated data model.
If you are using modeless forms with .Show then you should implement External Events to interact with Revit. In that approach you are letting the External Command that initially shows the dialogue to exit the context. You then communicate with Revit via raising external event that creates a new context when Revit is ready.
As noted in first paragraph however you can stay within the context via .ShowDialog for what you want to do. Code below is VB but you can achieve the same in C# with a while loop.
Private Function TObj76(ByVal commandData As Autodesk.Revit.UI.ExternalCommandData,
ByRef message As String, ByVal elements As Autodesk.Revit.DB.ElementSet) As Result
If commandData.Application.ActiveUIDocument Is Nothing Then Return Result.Cancelled Else
Dim UIDoc As UIDocument = commandData.Application.ActiveUIDocument
Dim Doc As Document = UIDoc.Document
Dim Res As List(Of String) = Nothing
Again:
Dim SelectItemWin As New SelectElementsWindow
SelectItemWin.ListBox_Results.ItemsSource = Nothing
SelectItemWin.ListBox_Results.ItemsSource = Res
SelectItemWin.ShowDialog()
Select Case SelectItemWin.Result
Case SelectElementsWindow.DiaResult.SelectElements
Dim R As New List(Of Reference)
Try
R = UIDoc.Selection.PickObjects(Selection.ObjectType.Element)
Catch ex As Exception
End Try
If R Is Nothing = False Then
Res = New List(Of String)
For i = 0 To R.Count - 1
Res.Add(CStr(R(i).ElementId.IntegerValue))
Next
End If
GoTo Again
Case Else
End Select
Return Result.Succeeded
End Function
External Command
Public Class SelectElementsWindow
Private IntRes As DiaResult = DiaResult.None
Public ReadOnly Property Result As DiaResult
Get
Return IntRes
End Get
End Property
Public Enum DiaResult
None = 0
SelectElements = 1
End Enum
Private Sub Button_Select_Click(sender As Object, e As RoutedEventArgs) Handles Button_Select.Click
IntRes = DiaResult.SelectElements
Me.Close()
End Sub
End Class
Window Code Behind
<Window x:Class="SelectElementsWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:RPT_RvtTests"
mc:Ignorable="d"
Title="Select Elements" Height="195.882" Width="427.647" WindowStyle="ToolWindow" ResizeMode="NoResize">
<Grid>
<Button Name="Button_Select" Content="Select" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="75"/>
<ListBox Name="ListBox_Results" Margin="10,35,10,10"/>
</Grid>
</Window>
Xaml for window