IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Silverlight Discussion :

[SL4 - RIA] Pas d'événement PropertyChanged


Sujet :

Silverlight

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Décembre 2003
    Messages
    259
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2003
    Messages : 259
    Par défaut [SL4 - RIA] Pas d'événement PropertyChanged
    Bonjour, j'ai une classe "Autorisation" qui hérite d'une classe entitybase héritant de INotifyPropertyChanged.
    Côté serveur si j'utilise ma classe Autorisation j'ai bien l'événement PropertyChanged, mais il disparait côté client. C'est à cause de RIA ? Comment faire pour pouvoir l'utiliser ?
    Merci !

    Ma classe EntityBase :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
     
     [DataContract]
        public class EntityBase : INotifyPropertyChanged
        {
     
            public event PropertyChangedEventHandler PropertyChanged;
     
               protected  void ValidateProperty(string propertyName, object value)
                {
                    Validator.ValidateProperty(value, new ValidationContext(this, null, null)
                    {
                        MemberName = propertyName,
                    });
                }
     
     
            protected void Validate(string propertyName, object value)
            {
                ValidateProperty(propertyName, value);
            }
     
     
            protected virtual void OnNotify(string propertyName)
            {
                PropertyChangedEventHandler handler = PropertyChanged;
                if (handler != null)
                {
                    handler(this, new PropertyChangedEventArgs(propertyName));
                }
            }
        }

  2. #2
    Expert confirmé
    Avatar de Skyounet
    Homme Profil pro
    Software Engineer
    Inscrit en
    Mars 2005
    Messages
    6 380
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Software Engineer
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2005
    Messages : 6 380
    Par défaut
    Hum. Normalement le code genere cote client contient egalement INotifyPropertyChanged (et IEditableObject par ailleurs).

    Si tu regardes le code genere tu ne les a pas ?

  3. #3
    Membre éclairé
    Profil pro
    Inscrit en
    Décembre 2003
    Messages
    259
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2003
    Messages : 259
    Par défaut
    Voici ce que j'ai dans le RIAServices.Web.g.cs :
    (mais je ne voit pas ces interface dans le code)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
      [DataContract(Namespace="http://schemas.datacontract.org/2004/07/mec.Businness.Objects")]
        public sealed partial class Autorisation : ComplexObject
        {...
    et :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
     
            namespace System.ServiceModel.DomainServices.Client
    {
        // Summary:
        //     Base class for all complex objects.
        [DataContract]
        public abstract class ComplexObject : INotifyPropertyChanged, IEditableObject, INotifyDataErrorInfo
        {
            // Summary:
            //     Gets a value indicating whether this instance has any validation errors.
            [Display(AutoGenerateField = false)]
            public bool HasValidationErrors { get; }
            //
            // Summary:
            //     Gets a value indicating whether this instance is currently being deserialized.
            protected internal bool IsDeserializing { get; }
            //
            // Summary:
            //     Gets the collection of validation errors for this instance.
            [Display(AutoGenerateField = false)]
            public ICollection<ValidationResult> ValidationErrors { get; }
     
            // Summary:
            //     Begin editing this instance
            protected void BeginEdit();
            //
            // Summary:
            //     Cancel any edits made to this instance since the last call to BeginEdit
            protected void CancelEdit();
            //
            // Summary:
            //     Commit the edits made to this instance since the last call to BeginEdit
            protected void EndEdit();
            //
            // Summary:
            //     Method called after this ComplexObject has been deserialized
            //
            // Parameters:
            //   context:
            //     The serialization context
            [OnDeserialized]
            [EditorBrowsable(EditorBrowsableState.Never)]
            public void OnDeserialized(StreamingContext context);
            //
            // Summary:
            //     Method called when this ComplexObject is being deserialized
            //
            // Parameters:
            //   context:
            //     The serialization context
            [OnDeserializing]
            [EditorBrowsable(EditorBrowsableState.Never)]
            public void OnDeserializing(StreamingContext context);
            //
            // Summary:
            //     Called when a System.ServiceModel.DomainServices.Client.ComplexObject property
            //     has changed.
            //
            // Parameters:
            //   e:
            //     The event arguments
            protected virtual void OnPropertyChanged(PropertyChangedEventArgs e);
            //
            // Summary:
            //     Called from a property setter to notify the framework that a System.ServiceModel.DomainServices.Client.ComplexObject
            //     data member has changed. This method performs any required change tracking
            //     and state transitions.
            //
            // Parameters:
            //   propertyName:
            //     The name of the property that has changed
            protected void RaiseDataMemberChanged(string propertyName);
            //
            // Summary:
            //     Called from a property setter to notify the framework that a System.ServiceModel.DomainServices.Client.ComplexObject
            //     data member is about to be changed. This method performs any required change
            //     tracking and state transition operations.
            //
            // Parameters:
            //   propertyName:
            //     The name of the property that is changing
            protected void RaiseDataMemberChanging(string propertyName);
            //
            // Summary:
            //     Called from a property setter to notify the framework that a System.ServiceModel.DomainServices.Client.ComplexObject
            //     property has changed. This method does not perform any change tracking operations.
            //
            // Parameters:
            //   propertyName:
            //     The name of the property that has changed
            protected void RaisePropertyChanged(string propertyName);
            //
            // Summary:
            //     Validate whether the specified value is valid for the specified property
            //     of the current ComplexObject.
            //
            // Parameters:
            //   propertyName:
            //     The name of the property to validate. This name cannot be null or empty.
            //
            //   value:
            //     The value to test. It may be null if null is valid for the given property.
            //
            // Exceptions:
            //   System.ArgumentNullException:
            //     is thrown if propertyName is null or empty.
            //
            //   System.InvalidOperationException:
            //     is thrown if this property is marked with System.ComponentModel.DataAnnotations.EditableAttribute
            //     configured to prevent editing.
            //
            // Remarks:
            //     This method evaluates all the System.ComponentModel.DataAnnotations.ValidationAttributes
            //     associated with the specified property, accumulating the validation errors
            //     and surfacing them through the System.ServiceModel.DomainServices.Client.ComplexObject.ValidationErrors
            //     property. It also verifies the property is not read-only.
            //     All validation logic is bypassed if this instance is currently being deserialized.
            protected void ValidateProperty(string propertyName, object value);
            //
            // Summary:
            //     Validate whether the specified property value is valid for the specified
            //     System.ComponentModel.DataAnnotations.ValidationContext.
            //
            // Parameters:
            //   validationContext:
            //     The System.ComponentModel.DataAnnotations.ValidationContext representing
            //     the validation to be performed.
            //     System.ComponentModel.DataAnnotations.ValidationContext.System.ComponentModel.DataAnnotations.ValidationContext.MemberName
            //     must indicate the name of the property to validate.
            //
            //   value:
            //     The value to test. It may be null if null is valid for the given property.
            //
            // Exceptions:
            //   System.ArgumentNullException:
            //     is thrown if validationContext is null.
            //
            // Remarks:
            //     This method evaluates all the System.ComponentModel.DataAnnotations.ValidationAttributes
            //     associated with the property indicated as the System.ComponentModel.DataAnnotations.ValidationContext.MemberName,
            //     accumulating the validation errors and surfacing them through the System.ServiceModel.DomainServices.Client.ComplexObject.ValidationErrors
            //     property.
            protected virtual void ValidateProperty(ValidationContext validationContext, object value);
    donc je devrais avoir l'evenement PropertyChanged...mais rien, juste mes propriétés, et les propiétés ValidationErrors et HasvalidationErrors...
    En fait je ne vois pas les protected...

  4. #4
    Expert confirmé
    Avatar de Skyounet
    Homme Profil pro
    Software Engineer
    Inscrit en
    Mars 2005
    Messages
    6 380
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Software Engineer
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2005
    Messages : 6 380
    Par défaut
    Comme tu peux voir ta classe implémente INotifyPropertyChanged. Tu as donc bien ton event PropertyChanged.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    public abstract class ComplexObject : INotifyPropertyChanged, IEditableObject, INotifyDataErrorInfo
    Tu as même la méthode RaisePropertyChanged qui s'occupe de lancer l'event quand un propriété change.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    protected void RaisePropertyChanged(string propertyName);

  5. #5
    Membre éclairé
    Profil pro
    Inscrit en
    Décembre 2003
    Messages
    259
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2003
    Messages : 259
    Par défaut
    hmmm mais pour quand je fais (coté client) :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Autorisation a = new Autorisation();
    dans a.???? je n'ai pas de PropertyChanged
    J'ai juste les propriétés de l'objet ainsi que celles que je mettais ci-dessus..

  6. #6
    Expert confirmé
    Avatar de Skyounet
    Homme Profil pro
    Software Engineer
    Inscrit en
    Mars 2005
    Messages
    6 380
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Software Engineer
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2005
    Messages : 6 380
    Par défaut
    Si tu cherches dans le .web.g.cs est-ce que tu vois l'event ? Si la classe implemente l'interface INotifyPropertyChanged alors c'est oblige que l'event soit la (mais il pourrait etre private par contre).

Discussions similaires

  1. [Lazarus] TStatusBar : Pas d'événement OnDrawPanel
    Par Louis Griffont dans le forum Lazarus
    Réponses: 5
    Dernier message: 19/03/2009, 19h05
  2. Pas d'événement OnClose quand on arrête W2K
    Par Altau dans le forum C++Builder
    Réponses: 9
    Dernier message: 26/01/2009, 18h36
  3. évènement crée postback mais pas l'évènement serveur
    Par phfle1 dans le forum Windows Forms
    Réponses: 5
    Dernier message: 24/09/2008, 17h53
  4. Réponses: 3
    Dernier message: 01/07/2008, 08h25
  5. Réponses: 3
    Dernier message: 18/05/2007, 15h26

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo