d5d303cc48
- Aggiustato il taglio dell'ultima riga nel DataGrid anche per SearchProduct
34 lines
1.5 KiB
VB.net
34 lines
1.5 KiB
VB.net
Class SearchProductPageV
|
|
|
|
Private Sub Grid_Loaded(sender As Object, e As RoutedEventArgs)
|
|
Dim visibleRows As Integer = 0
|
|
Dim i As Integer = 0
|
|
If (ProductDataGrid.Height - ProductDataGrid.ColumnHeaderHeight) Mod ProductDataGrid.RowHeight <> 0 Then
|
|
For Each DataGridItem In ProductDataGrid.ItemContainerGenerator.Items ' ContainerFromIndex(i)
|
|
If IsUserVisible(CType(ProductDataGrid.ItemContainerGenerator.ContainerFromIndex(i), FrameworkElement), ProductDataGrid) Then
|
|
visibleRows += 1
|
|
Else
|
|
Exit For
|
|
End If
|
|
i = i + 1
|
|
Next
|
|
'If (ClientDataGrid.Height < ClientDataGrid.ColumnHeaderHeight + ClientDataGrid.RowHeight * (visibleRows - 1)) Then
|
|
ProductDataGrid.Height = ProductDataGrid.ColumnHeaderHeight + ProductDataGrid.RowHeight * (visibleRows - 1)
|
|
'End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Function IsUserVisible(element As FrameworkElement, container As FrameworkElement) As Boolean
|
|
If Not IsNothing(element) Then
|
|
If Not element.IsVisible Then
|
|
Return False
|
|
End If
|
|
Dim bounds As Rect = element.TransformToAncestor(container).TransformBounds(New Rect(0.0, 0.0, element.ActualWidth, element.ActualHeight))
|
|
Dim Rect = New Rect(0.0, 0.0, container.ActualWidth, container.ActualHeight)
|
|
Return Rect.Contains(bounds.TopLeft) Or Rect.Contains(bounds.BottomRight)
|
|
End If
|
|
Return False
|
|
End Function
|
|
|
|
End Class
|