Thanks to all for getting me started! So I ended up creating an ObservableCollection class & binded my listbox to a property of that class (atttribute tag)... Everything seems to be working (so far...). That WPF/XAML mountain is hard to climb...
Private Sub SelectTargetedBlock_Click(sender As Object, e As Windows.RoutedEventArgs) Handles SelectTargetedBlock.Click
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Dim db As Database = doc.Database
'this - is the modal dialog box.
Using UI As EditorUserInteraction = ed.StartUserInteraction(Me)
Dim entResult As PromptEntityResult = ed.GetEntity(vbLf & "Select entity")
If entResult.Status <> PromptStatus.OK Then
Return
End If
Using Tx As Transaction = db.TransactionManager.StartTransaction()
' Dim obj As DBObject = Tx.GetObject(entResult.ObjectId, OpenMode.ForRead)
Dim BlkRef As BlockReference = Tx.GetObject(entResult.ObjectId, OpenMode.ForRead)
If BlkRef.AttributeCollection IsNot Nothing Then
Dim attCol As AttributeCollection = BlkRef.AttributeCollection
For Each attId As ObjectId In attCol
Dim attRef As AttributeReference = TryCast(Tx.GetObject(attId, OpenMode.ForRead), AttributeReference)
MyObjectSource.Add(New MyAttribute With {
.BlkTagToLookAt = attRef.Tag,
.DestinationBlkName = attRef.BlockName})
Next
End If
Tx.Commit()
End Using
End Using
Dim b As New Binding("BlkTagToLookAt")
b.Mode = BindingMode.OneWay
b.Source = MyObjectSource
BindingOperations.SetBinding(MyListBox, TextBox.TextProperty, b)
MyListBox.DataContext = MyObjectSource