Perhaps it is a simple answer but I tried a lot of things without success. The problem is that my "PropertyChange" is always null in spite _gauges have values as picture at annex. UPDATE - I added more code (WpfControl is where WindowsFormsHost is defined. MyControl is the "Form" that is hosted at my WPF App
StackPanel
<StackPanel>
<local:WpfControl Width="500" GaugesStatus="{Binding Gauge}" />
</StackPanel>
ViewModel
public class ViewModel : INotifyPropertyChanged
{
public static readonly ViewModel instanceRet = new ViewModel();
public ViewModel()
{
}
public static ViewModel InstanceRet => instanceRet;
private Gauges _gauges;
public Gauges Gauge
{
get { return _gauges; }
set
{
_gauges = value;
OnPropertyChanged("Gauge");
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
Code behind
public test()
{
InitializeComponent();
DataContext = new ViewModel();
if (AltAircraft.Text != "AltAircraft")
{
Gauges gauge = new Gauges();
gauge = new Gauges
{
Altitude = Convert.ToDouble(AltAircraft.Text),
AirSpeed = zSpeedKTS,
Heading = headingToWp,
PitchAngle = 0.123,
RollAngle = 0, TurnRate = 0
};
ViewModel.InstanceRet.Gauge=gauge;
}
public class Gauges
{
public double TurnRate { get; set; }
public double Altitude { get; set; }
public double RollAngle { get; set; }
public double PitchAngle { get; set; }
public double VerticalSpeed { get; set; }
public double Heading { get; set; }
public double AirSpeed { get; set; }
}
WpfControl
<UserControl x:Class="Testminimums.WpfControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:TestMinimums"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="600">
<WindowsFormsHost Name="MyHost">
<local:MyControl />
</WindowsFormsHost>
</UserControl>
