Problem polega na tym, że należy dodać obsługę do w każdym wierszu na siatce danych. Są to 3 proste kroki.
Fist wynik, zawiadomienie niż można powiązać wszystkie wiersz lub jedną kontrolę w rzędzie:
- Krok 1. Deklaruj konwerter. Zakładam, że twój konwerter działa dobrze.
To mój konwerter:
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
- Krok 2 i 3. Bind DataGrid i DataGrid wierszy:
Oprawa DataGrid na 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
To obsługi dla DataGrid.Wiązanie z everyrow funkcję Wewnątrz:
Private Sub bindejarDataGrid(
sender As Object,
e As Microsoft.LightSwitch.Presentation.ControlAvailableEventArgs)
AddHandler DirectCast(e.Control, Windows.Controls.DataGrid
).LoadingRow, AddressOf bindejar
End Sub
wiążące jakiś wiersz sterowania dla każdego wiersza:
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
dzięki:
Czy dodajesz to do kodu ekranu? a twoja własność jest lokalna dla tego ekranu? – TsSkTo
Dodaję to do kodu ekranu. Właściwość znajduje się w źródle danych, ale jest również wyświetlana na tym ekranie. –
Zrobiłem coś podobnego, ale związałem moje kontrole w Xaml. Jeśli ten kod zostanie dodany do ekranu, twoje jednostki powinny pojawić się w kontekście danych ekranów. 'this.customers.FirstName' lub' this.CreatedScreenScreenProperty' w języku xaml ścieżka do tych właściwości została poprzedzona przez "Screen", np. '{Binding Path =" Screen.MyProperty Mode = "TwoWay}' – TsSkTo