TextBox не изменяет свойство
TextBox находится в GroupBox, который находится в вложенном в ScrollViever Grid'е. Перепробовал уже все, так как количество стержней динамически меняется нет возможности задать через Xaml
class RodTextBox : TextBox
{
public RodTextBox(string text,string propertyName, Rod rod)
{
Text = text;
TextWrapping = TextWrapping.Wrap;
addBinding(propertyName ,rod);
DataContext = rod;
GotFocus += clearTextOnFocus;
}
public void addBinding(string propertyName, Rod rod )
{
Binding myBinding = new Binding($"{propertyName}");
myBinding.Source = rod;
myBinding.UpdateSourceTrigger = UpdateSourceTrigger.LostFocus;
myBinding.Mode = BindingMode.TwoWay;
SetBinding(TextBlock.TextProperty, myBinding);
}
public void clearTextOnFocus(object sender, RoutedEventArgs e)
{
Text = String.Empty;
}
}
class Rod : INotifyPropertyChanged
{
public Rod (int number, int sqare,int length,int elastic)
{
Number = number;
Sqare = sqare;
Length = length;
Elastic = elastic;
}
int _Number;
int _Sqare;
int _Length;
int _Elastic;
public int Number
{
get
{
return _Number;
}
set
{
_Number = value;
NotifyPropertyChanged("Number");
}
}
public int Sqare
{
get
{
return _Sqare;
}
set
{
_Sqare = value;
NotifyPropertyChanged("Sqare");
}
}
public int Elastic
{
get
{
return _Elastic;
}
set
{
_Elastic = value;
NotifyPropertyChanged("Elastic");
}
}
public int Length
{
get
{
return _Length;
}
set
{
_Length = value;
NotifyPropertyChanged("Length");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}