Quelle confiance ...
Non sans rire, le code tel que l'ai écrit ne compile tout simplement pas.
Le message d'erreur est :
Argument not specified for parameter 'propertyPath' of 'Public Function CreateOneWayBinding(bindingSource As System.ComponentModel.INotifyPropertyChanged, propertyPath As String, [converter As System.Windows.Data.IValueConverter = Nothing]) As System.Windows.Data.Binding'
En fait, dans LoginStatus.xaml.vb, j'essaie de changer le nom de login ASP défini par:
Me.welcomeText.SetBinding(TextBlock.TextProperty, WebContext.Current.CreateOneWayBinding("User.DisplayName", New StringFormatValueConverter(ApplicationStrings.WelcomeMessage)))
par un nom que je défini ailleurs.
Pour tenir compte de ta remarque, j'ai changé ma clsGlobal par:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Public Class clsGlobal
Implements System.ComponentModel.INotifyPropertyChanged
Private Shared m_JUserNom As String = ""
Public Shared Property JUserNom() As String
Get
Return m_JUserNom
End Get
Set(ByVal value As String)
m_JUserNom = value
'Désactivation du RaiseEvent qui génère une erreur dans une Shared Property
'RaiseEvent PropertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs("JUserNom"))
End Set
End Property
Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
End Class |
Il faut noter que le code original fait appel à :
WebContext.Current.CreateOneWayBinding
Comme mon JUserNom ne fait pas partie du WebContext, je suppose que je dois plutôt faire un :
DataContext.CreateOneWayBinding
Si j'essaie:
Me.welcomeText.SetBinding(TextBlock.TextProperty, DataContext.CreateOneWayBinding(clsGlobal, "JUserNom"))
mais je reçois le message suivant:
'clsGlobal' is a type and cannot be used as an expression.
Partager