我正在創建一個貸款計算器,我有3個文本框,我試圖去反映出另一個。在我更改其中一個文本框的輸入後,我想讓其他2根據輸入重新計算,方法是按下我的程序中的計算按鈕,或者在文本框失去焦點後按下。屬性值反映了他人的
的三個文本框我有被綁定到會在這個程序被運行以及在運行時可以改變的能力,設置一定的值:
<TextBox Width="55" Height="23" Style="{StaticResource ResourceKey=StandardTextbox}" Text="{Binding StringFormat={}{0:P}, Path=CurrentLoan.PropertyTaxRate, Converter={StaticResource TextBoxToDecimalConverter1}}"/>
<TextBox Width="65" Height="23" Style="{StaticResource ResourceKey=StandardTextbox}" Text="{Binding StringFormat={}{0:C}, Path=CurrentLoan.PropertyTaxMonth, Converter={StaticResource TextBoxToDecimalConverter1}}"/>
<TextBox Width="65" Height="23" Style="{StaticResource ResourceKey=StandardTextbox}" Text="{Binding StringFormat={}{0:C}, Path=CurrentLoan.PropertyTaxYear, Converter={StaticResource TextBoxToDecimalConverter1}}"/>
CurrentLoan.PropertyTaxRate = .012;
CurrentLoan.PropertyTaxMonth = 250;
CurrentLoan.PropertyTaxYear = 3000;
SharedValues.HomeValue = 250000;
對於具有價值的家250,000美元,稅率爲1.2%,每年支付3000美元(250,000 * .012),每月支付250美元(一年3,000/12個月)。
而且我有已經聲明,像這樣的屬性:
public double PropertyTaxRate
{
get { return _propertyTaxRate; }
set { SetValueAndNotify(() => PropertyTaxRate, ref _propertyTaxRate, (value > 1) ? value/100 : value); }
}
public double PropertyTaxMonth
{
get { return _propertyTaxMonth; }
set { SetValueAndNotify(() => PropertyTaxMonth, ref _propertyTaxMonth, value); }
}
public double PropertyTaxYear
{
get{ return _propertyTaxYear; }
set { SetValueAndNotify(() => PropertyTaxYear, ref _propertyTaxYear, value); }
}
的SetValueAndNotify方法只是簡單地將值設置爲後盾財產,並通知物業已經使用INotifyPropertyChanged的改變的GUI。
說如果我將PropertyTaxYear屬性更改爲$ 6000,我希望PropertyTaxMonth更改爲$ 500,PropertyTaxRate更改爲2.4%。任何人有關於如何做到這一點的想法,並使這些屬性相互反映?先進的謝謝您的意見!
什麼問題? – Rahul
對不起。在最後一段中更清楚。 –
SetAndNotify使用INotifyPropertyChanged? – Berryl