0
如果值不同於550,則無法理解如何禁用文本框。如果初始值與550不同,則對所有值禁用該值,如果初始值等於550,則對所有值禁用該值。問題它是否會更新當我更改UI中的值。WPF IsEnabled綁定
這裏是我的XAML
<src:CustomTextBox VerticalAlignment = "Center"
Text="{Binding TrafoProperties.InsulationLevels.LightningImpulseVoltage,
UpdateSourceTrigger = PropertyChanged,
Mode = TwoWay,
ValidatesOnNotifyDataErrors = True,
NotifyOnValidationError = True}"
Validation.ErrorTemplate = "{StaticResource defaultErrorTemplate}"
IsEnabled="{Binding Path = TrafoProperties.InsulationLevels.IsEnabled, Mode = TwoWay}"/>
和我的兩個propeteries
public double LightningImpulseVoltage
{
get { return _LightningImpulseVoltage; }
set
{
SetProperty(ref _LightningImpulseVoltage, value);
if (OnLightningImpulseVoltage != null)
OnLightningImpulseVoltage();
}
}
public bool IsEnabled
{
get { return LightningImpulseVoltage == 550; }
set
{
OnPropertyChanged("LightningImpulseVoltage");
}
}
我的SetProperty
protected bool SetProperty<T>(ref T storage, T value, [CallerMemberName] String propertyName = null)
{
if (object.Equals(storage, value))
return false;
storage = value;
this.OnPropertyChanged(propertyName);
return true;
}
而且我OnPropertyChanged
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var eventHandler = this.PropertyChanged;
if (eventHandler != null)
{
eventHandler(this, new PropertyChangedEventArgs(propertyName));
}
}
,你可以把一個scrren鏡頭描述你基本上是做什麼 –
@HakamFostok我正在從下拉框中選擇值,並在文本框中的值被禁用正在改變 – user3290117
我沒有看到你曾經爲「IsEnabled」提升'PropertyChanged'。 –