I have two search text boxes, Above
and Below
, that I have to set restrains on.
The number in Below
can't be higher than the number in Above
and the number in Above
can't be lower than the one in Below
.
If one number is not right, it will should be set equal to the other number.
The problem is that Above
doesn't get updated,
while Bottom
does (even though the properties are set in the same way).
xaml:
<common:SearchTextBox Grid.Column="1"
VerticalAlignment="Center"
Label="Enter value in feet"
common:AllowableTextInput.IsIgnoreWhiteSpace="True"
common:AllowableTextInput.IsMatch="^[0-9]{0,5}$"
Text="{Binding Path=AboveAircraft, UpdateSourceTrigger=PropertyChanged,
Converter={StaticResource AboveAircraftConveter}, ConverterParameter=4000}"/>
<Label Grid.Row="1" Grid.Column="0"
Style="{StaticResource FormLabelStyle}"
Content="Below Aircraft (ft):"/>
<common:SearchTextBox Grid.Row="1" Grid.Column="1"
VerticalAlignment="Center" HorizontalAlignment="Stretch"
common:AllowableTextInput.IsIgnoreWhiteSpace="True"
common:AllowableTextInput.IsMatch="^[0-9]{0,5}$"
Text="{Binding Path=BelowAircraft, UpdateSourceTrigger=PropertyChanged,
Converter={StaticResource BelowAircraftConveter}, ConverterParameter=2000}"
Label="Enter value in feet" />
C#:
public int AboveAircraft
{
get { return _above; }
set
{
if (SetProperty(ref _above, value, "AboveAircraft") && _updateModel)
{
if (Model.AltitudeBand == null)
{
Model.AltitudeBand = new AltitudeBand();
}
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("AboveAircraft"));
if (_above < _below)
{
_below = AboveAircraft;
}
}
Model.AltitudeBand.Above = new AltitudeBandLimit() { Unit = AltitudeUnit.Foot, Value = _above };
}
}
}
/// <summary>
/// Below the route of flight in ft
/// </summary>
public int BelowAircraft
{
get { return _below; }
set
{
if (SetProperty(ref _below, value, "BelowAircraft") && _updateModel)
{
if (Model.AltitudeBand == null)
{
Model.AltitudeBand = new AltitudeBand();
}
if (PropertyChanged != null)
{
_below = value;
PropertyChanged(this, new PropertyChangedEventArgs("BelowAircraft"));
if (_below > _above)
{
AboveAircraft = _below;
}
}
Model.AltitudeBand.Below = new AltitudeBandLimit() { Unit = AltitudeUnit.Foot, Value = _below };
}
}
}