我有一个 DataGrid - 有
一个隐藏列 (SubjectFull) 和一个包含最多 60 个主题的可见列,称为“Subject”。
名为“未读”的栏 - 这是尚未未读的情况下的图像。
我可以获得一个工具提示来仅显示网格可见部分的SubjectFull 值,但是当我向下滚动时它就会变得混乱。
For Each row As DataRowView In DGV.Items.OfType(Of DataRowView)
Dim DGRow As DevComponents.WPF.Controls.AdvGridRow = DGV.ItemContainerManager.ContainerFromItem(row, True)
Dim vTooltip As String = row("SubjectFull")
DGRow.ToolTip = vTooltip
Next
我正在尝试使用
来解决这个问题 Dim DGV As New DGVx
With DGV
.Name = "Inbox_DGV"
.ContextMenu = ReturnContexMenu()
End With
RegisterControl(Inbox_Grid, DGV)
Grid.SetRow(DGV, 1)
Inbox_Grid.Children.Add(DGV)
Dim vStyle As New Style(GetType(DevComponents.WPF.Controls.AdvGridRow))
Dim vSetter As New Setter
With vSetter
.Property = DevComponents.WPF.Controls.AdvGridRow.IsSelectedProperty
.Value = New Binding("Select") With {.Mode = BindingMode.TwoWay}
End With
Dim vSetter2 As New Setter
With vSetter2
.Property = DevComponents.WPF.Controls.AdvGridRow.ForegroundProperty
.Value = New Binding("Unread") With {.Mode = BindingMode.TwoWay}
End With
vStyle.Setters.Add(vSetter)
vStyle.Setters.Add(vSetter2)
DGV.Resources.Add(GetType(DevComponents.WPF.Controls.AdvGridRow), vStyle)
复选框(选择)的绑定效果很好,但我正在努力寻找一种方法将字符串从隐藏列绑定到行,并为存在未读图像的行分配颜色。
任何指点,将不胜感激
更新 - 我现在可以使用工具提示,并且有另一个隐藏的整数字段来表示“读取” - 如果值为 0,则该行需要为红色,否则为默认值(或黑色)
Dim vStyle As New
Style(GetType(DevComponents.WPF.Controls.AdvGridRow))
Dim vSetter As New Setter
With vSetter
.Property = DevComponents.WPF.Controls.AdvGridRow.IsSelectedProperty
.Value = New Binding("Select") With {.Mode = BindingMode.TwoWay}
End With
Dim vSetter2 As New Setter
With vSetter2
.Property = DevComponents.WPF.Controls.AdvGridRow.ToolTipProperty
.Value = New Binding("SubjectFull") With {.BindsDirectlyToSource = True}
End With
Dim vSetter3 As New Setter
With vSetter3
.Property = DevComponents.WPF.Controls.AdvGridRow.ForegroundProperty
.Value = Brushes.Red '<--------This needs to be the value if FlagRead = 1
End With
With vStyle.Setters
.Add(vSetter)
.Add(vSetter2)
.Add(vSetter3)
End With
DGV.Resources.Add(GetType(DevComponents.WPF.Controls.AdvGridRow), vStyle)
弄清楚了:-)
Dim vStyle As New Style(GetType(DevComponents.WPF.Controls.AdvGridRow))
Dim vSetter As New Setter
With vSetter
.Property = DevComponents.WPF.Controls.AdvGridRow.IsSelectedProperty
.Value = New Binding("Select") With {.Mode = BindingMode.TwoWay}
End With
Dim vSetter2 As New Setter
With vSetter2
.Property = DevComponents.WPF.Controls.AdvGridRow.ToolTipProperty
.Value = New Binding("SubjectFull") With {.BindsDirectlyToSource = True}
End With
Dim vSetter3 As New Setter
With vSetter3
.Property = DevComponents.WPF.Controls.AdvGridRow.ForegroundProperty
.Value = Brushes.Red
End With
Dim vTrigger As New DataTrigger
With vTrigger
.Binding = New Binding("FlagReadFull")
.Value = 0
.Setters.Add(vSetter3)
End With
With vStyle.Setters
.Add(vSetter)
.Add(vSetter2)
End With
vStyle.Triggers.Add(vTrigger)
DGV.Resources.Add(GetType(DevComponents.WPF.Controls.AdvGridRow), vStyle)