的問題是,你應該在數據網格添加一個處理程序每一行。他們是3個簡單的步驟。
拳的結果,通知比可以綁定所有行或單個控制在排:
這是我的轉換器:
Public Class BooleanDateConverter
Implements System.Windows.Data.IValueConverter
Public Function Convert(ByVal value As Object,
ByVal targetType As System.Type,
ByVal parameter As Object,
ByVal culture As System.Globalization.CultureInfo) _
As Object Implements System.Windows.Data.IValueConverter.Convert
If DirectCast(value, Boolean) Then
Return New System.Windows.Media.SolidColorBrush(
System.Windows.Media.Color.FromArgb(170, 102, 255, 245))
Else
Return New System.Windows.Media.SolidColorBrush(
System.Windows.Media.Color.FromArgb(170, 255, 0, 0))
End If
End Function
Public Function ConvertBack(ByVal value As Object,
ByVal targetType As System.Type,
ByVal parameter As Object,
ByVal culture As System.Globalization.CultureInfo) _
As Object Implements System.Windows.Data.IValueConverter.ConvertBack
Return Nothing
End Function
End Class
- 步驟2和3。綁定的DataGrid和DataGrid行:在InitializeDataWorkspace
綁定數據網格:
Private Sub Conversio_CategoriaPDI_a_ElementDeCosts_InitializeDataWorkspace(
saveChangesTo As System.Collections.Generic.List(
Of Microsoft.LightSwitch.IDataService))
AddHandler Me.FindControl(
"TConversio_CategoriaPDI_a_ElementDeCosts"
).ControlAvailable, AddressOf bindejarDataGrid
End Sub
這是數據網格的處理程序。結合everyrow內部功能:
Private Sub bindejarDataGrid(
sender As Object,
e As Microsoft.LightSwitch.Presentation.ControlAvailableEventArgs)
AddHandler DirectCast(e.Control, Windows.Controls.DataGrid
).LoadingRow, AddressOf bindejar
End Sub
結合一些控制行的每一行:
Private Sub bindejar(sender As Object,
e As Windows.Controls.DataGridRowEventArgs)
Dim b As Windows.Data.Binding = New Windows.Data.Binding("parametritzat")
b.Mode = Windows.Data.BindingMode.OneTime
b.Converter = New BooleanDateConverter
b.ValidatesOnExceptions = True
e.Row.SetBinding(System.Windows.Controls.Label.BackgroundProperty, b)
End Sub
感謝:
你是否將此添加到屏幕代碼?你的財產是在那個屏幕上的本地? – TsSkTo
我將此添加到屏幕代碼。該屬性位於數據源中,但也顯示在該屏幕上。 –
我做了類似的事情,但在xaml中綁定了我的控件。如果將此代碼添加到屏幕中,則您的實體應顯示在屏幕數據上下文中。 xaml中的'this.customers.FirstName'或'this.CreatedScreenProperty'這些屬性的路徑前面是「屏幕」,比如'{Binding Path =「Screen.MyProperty Mode =」TwoWay}「 – TsSkTo