I am trying to set up a display screen for a voltage source, it has multiple otuput and set values that are all of the same type. I cant get a struct or a class to store these values to work.
Class that stores variables
class DualOutput
{
private readonly double minVoltage = -1.5;
private readonly double maxVoltage = 1.5;
private double setVoltage;
public double SetVoltage
{
get => setVoltage;
set
{
value = value < minVoltage ? minVoltage : value > maxVoltage ? maxVoltage : value;
setVoltage = value;
}
}
public double Voltage { get; set; }
public double Current { get; set; }
}
Code that is in the main, dataContext class. [AddINotifyPropertyChangedInterface]
is also added to this class
public DualOutput DualOutput1 = new DualOutput()
{
SetVoltage = 0,
Voltage = 0,
Current = 0
};
public DualOutput DualOutput2 = new DualOutput();
The XAML for the portion I am trying to show:
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding DualOutput1.SetVoltage, StringFormat={}{0:N3} kV}" Style="{StaticResource SetterBox}"/>
<TextBox Grid.Row="0" Grid.Column="2" Text="{Binding DualOutput1.Voltage, StringFormat={}{0:N3} kV}" Style="{StaticResource GetterBox}"/>
<TextBox Grid.Row="0" Grid.Column="3" Text="{Binding DualOutput1.Current, StringFormat={}{0:N2} uA}" Style="{StaticResource GetterBox}"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding DualOutput2.SetVoltage, StringFormat={}{0:N3} kV}" Style="{StaticResource SetterBox}"/>
<TextBox Grid.Row="1" Grid.Column="2" Text="{Binding DualOutput2.Voltage, StringFormat={}{0:N3} kV}" Style="{StaticResource GetterBox}"/>
<TextBox Grid.Row="1" Grid.Column="3" Text="{Binding DualOutput2.Current, StringFormat={}{0:N2} uA}" Style="{StaticResource GetterBox}"/>
As you can see, i have tried starting the class both setting and not setting the values.
Am I binding to the values incorrectly?
I have tried using both a class and a struct for DualOutput
. I don't get error messages, there are just no values displayed.