Bonjour,
A nouveau j'ai besoin de votre aide, donc voici mon nouveau problème:
Je souhaite faire un binding avec une Class. chose simple me direz vous? mais je n'y arrive pas.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
private KvhClassData _kvhVars;
public KvhClassData KvhVars
        {
            get { return _kvhVars; }
            set { _kvhVars = value; }
        }
 
public MainWindow()
        {
            InitializeComponent();
            this.DataContext = this;
 
            _kvhVars = new KvhClassData();
        }
Dans un timer:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
this.KvhVars.KvhYaw = DateTime.Now.Millisecond.ToString();
La Class:
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
public class KvhClassData : INotifyPropertyChanged
    {
 
        private String _KvhYaw = "";
 
        public event PropertyChangedEventHandler PropertyChanged;
 
        public string KvhYaw
        {
            get { return this._KvhYaw; }
            set
            {
                if (this._KvhYaw != value)
                {
                    this._KvhYaw = value;
                    this.OnPropertyChanged("KvhYaw");
                }
            }
        }
 
        public KvhClassData()
        {
 
        }
 
        protected void OnPropertyChanged(string name)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(name));
            }
        }
    }
Et le code Xaml:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
<TextBlock Height="23" Name="textBlock7" Text="{Binding KvhVars.KvhYaw}" />
Je ne voi pas les millisecondes dans le textbox, avez vous une idées?
D'avance merci.