For ease of use, it may be of interest to highlight a row in a table. The table is created using a grid, filled with borders (spanning the entire row), labels and textboxes. On getting focus of any of the textboxes, the border-element in that row is chosen and highlighted. On losing focus, it is dimmed again.
The table is created on runtime.
Handlers are added to handle focus events of the Textboxes
using one common procedure.
The handler then determines the row and highlights the border element by looking for the first element in that row.
Using the Code
The main task was to find the border element in any given row.
This is done using the procedure
Private Sub setRowColor(ByVal row As Integer, ByVal myBrush As Brush)
Dim column As Integer = 0
Dim el As Border = Me.Grid1.Children.Cast(Of UIElement)().First( _
Function(uiEl) Grid.GetRow(uiEl) = row AndAlso Grid.GetColumn(uiEl) = column)
el.Background = myBrush
Points of Interest
Tables in WPF may be defined programmatically with some knowledge. The aim of row highlighting was done using borders with defined background.