Is it possible to instruct Fody to generate PropertyChanged Events for the Properties Color1 and Color2 if the corresponding Items in the ObservableCollection _colors are changing?
public class MyModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public string Name { get; set; }
public Brush Color1 => _colors[0];
public Brush Color2 => _colors[1];
private ObservableCollection<Brush> _colors;
public MyModel()
{
_colors = new ObservableCollection<Brush>()
{
Brushes.Transparent,
Brushes.Black,
};
}
public void DoSomething()
{
_colors[0] = Brushes.Green;
_colors[1] = Brushes.Red;
}
protected void OnPropertyChanged(PropertyChangedEventArgs eventArgs)
{
PropertyChanged?.Invoke(this, eventArgs);
}
}
For the Name Property the Event will be generated, but not for Color1 and Color2 (see extract from ILSpy):
public string Name
{
[CompilerGenerated]
get
{
return <Name>k__BackingField;
}
[CompilerGenerated]
set
{
if (!string.Equals(<Name>k__BackingField, value, StringComparison.Ordinal))
{
<Name>k__BackingField = value;
OnPropertyChanged(<>PropertyChangedEventArgs.Name);
}
}
}
public Brush Color1 => _colors[0];
public Brush Color2 => _colors[1];