Hello
I don't understand why my binding do not work.
I have an XML file with a Binding Text :
<TextBlock TextWrapping="Wrap" Text="{Binding strSelectionLignes}" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2" />
In my C# code, i have been use INotifyPropertyChanged :
public partial class ParamsAffichage : Window, INotifyPropertyChanged
{
#region Évenement qui permet de déclencher l'événement INotifyPropertyChanged et mettre à jour le binding
public void Set<TValue>(ref TValue field, TValue newValue, [CallerMemberName] string propertyName = "")
{
if (EqualityComparer<TValue>.Default.Equals(field, default(TValue)) || !field.Equals(newValue))
{
field = newValue;
if (PropertyChanged != null)
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
public event PropertyChangedEventHandler PropertyChanged;
#endregion
private string _strSelectionLignes;
public string strSelectionLignes
{
get { return _strSelectionLignes; }
set { Set(ref _strSelectionLignes, value); }
}
I modify my varaible strSelectionLignes :
public ParamsAffichage()
{
InitializeComponent();
strSelectionLignes = "TEST";
}
But "TEST" is not visible in my form
Why ?
Thank you very much
What I have tried:
I try in debug, in this test :
if (PropertyChanged != null)
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
PropertyChanged is alwys null.