私は、ViewModelのプロパティMinDurationにTextBoxをバインドしています。 MinDurationは常にViewModelのDurationプロパティ以下である必要があります。だから、私のXAML:「最終値を使用していますが」WPFバインディングが正しく機能していません
<TextBox Text="{Binding BasePO.MinDuration, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
そして、私のプロパティがあります:
のでprivate double minDuration;
public double MinDuration
{
get { return minDuration; }
set
{
if (value > Duration)
minDuration = Duration;
else
minDuration = value;
OnPropertyChanged("MinDuration");
}
}
は、期間= 40をしましょう。さて、その結合の結果である: - 私は5を入れ、その後場合>テキストボックスが表示さ4
- >のテキストボックスには、40(正解!)が表示さ
しかしが、問題がある: - 私は0を入れ、その後場合>テキストボックスが表示さ4
- >テキストボックスは40 を表示します
- たとえば5を入力すると(値は405) - > TextBoxは405を表示します(なぜ?)
は、結合の跡があります:
私は入れSystem.Windows.Data Warning: 90 : BindingExpression (hash=22334206): Update - got raw value '4'
System.Windows.Data Warning: 93 : BindingExpression (hash=22334206): Update - implicit converter produced '4'
System.Windows.Data Warning: 94 : BindingExpression (hash=22334206): Update - using final value '4'
System.Windows.Data Warning: 102 : BindingExpression (hash=22334206): SetValue at level 1 to PO (hash=59829654) using RuntimePropertyInfo(MinDuration): '4'
System.Windows.Data Warning: 95 : BindingExpression (hash=22334206): Got PropertyChanged event from PO (hash=59829654)
System.Windows.Data Warning: 101 : BindingExpression (hash=22334206): GetValue at level 0 from PoTableForm (hash=53931641) using RuntimePropertyInfo(BasePO): PO (hash=59829654)
System.Windows.Data Warning: 101 : BindingExpression (hash=22334206): GetValue at level 1 from PO (hash=59829654) using RuntimePropertyInfo(MinDuration): '4'
System.Windows.Data Warning: 80 : BindingExpression (hash=22334206): TransferValue - got raw value '4'
System.Windows.Data Warning: 84 : BindingExpression (hash=22334206): TransferValue - implicit converter produced '4'
System.Windows.Data Warning: 89 : BindingExpression (hash=22334206): TransferValue - using final value '4'
Поток '<Без имени>' (0x19b4) завершился с кодом 0 (0x0).
System.Windows.Data Warning: 90 : BindingExpression (hash=22334206): Update - got raw value '45'
System.Windows.Data Warning: 93 : BindingExpression (hash=22334206): Update - implicit converter produced '45'
System.Windows.Data Warning: 94 : BindingExpression (hash=22334206): Update - using final value '45'
System.Windows.Data Warning: 102 : BindingExpression (hash=22334206): SetValue at level 1 to PO (hash=59829654) using RuntimePropertyInfo(MinDuration): '45'
System.Windows.Data Warning: 95 : BindingExpression (hash=22334206): Got PropertyChanged event from PO (hash=59829654)
System.Windows.Data Warning: 101 : BindingExpression (hash=22334206): GetValue at level 0 from PoTableForm (hash=53931641) using RuntimePropertyInfo(BasePO): PO (hash=59829654)
System.Windows.Data Warning: 101 : BindingExpression (hash=22334206): GetValue at level 1 from PO (hash=59829654) using RuntimePropertyInfo(MinDuration): '40'
System.Windows.Data Warning: 80 : BindingExpression (hash=22334206): TransferValue - got raw value '40'
System.Windows.Data Warning: 84 : BindingExpression (hash=22334206): TransferValue - implicit converter produced '40'
System.Windows.Data Warning: 89 : BindingExpression (hash=22334206): TransferValue - using final value '40'
System.Windows.Data Warning: 90 : BindingExpression (hash=22334206): Update - got raw value '405'
System.Windows.Data Warning: 93 : BindingExpression (hash=22334206): Update - implicit converter produced '405'
System.Windows.Data Warning: 94 : BindingExpression (hash=22334206): Update - using final value '405'
System.Windows.Data Warning: 102 : BindingExpression (hash=22334206): SetValue at level 1 to PO (hash=59829654) using RuntimePropertyInfo(MinDuration): '405'
System.Windows.Data Warning: 95 : BindingExpression (hash=22334206): Got PropertyChanged event from PO (hash=59829654)
System.Windows.Data Warning: 101 : BindingExpression (hash=22334206): GetValue at level 0 from PoTableForm (hash=53931641) using RuntimePropertyInfo(BasePO): PO (hash=59829654)
System.Windows.Data Warning: 101 : BindingExpression (hash=22334206): GetValue at level 1 from PO (hash=59829654) using RuntimePropertyInfo(MinDuration): '40'
System.Windows.Data Warning: 80 : BindingExpression (hash=22334206): TransferValue - got raw value '40'
System.Windows.Data Warning: 84 : BindingExpression (hash=22334206): TransferValue - implicit converter produced '40'
System.Windows.Data Warning: 89 : BindingExpression (hash=22334206): TransferValue - using final value '40'
あなたが見ることができるように、「40」が、テキストボックスが表示さ405とし、最終的な値を使用して405 結合のために働いていませんすべての数字は40から始まります(この例では)。
どのバージョンのフレームワークをターゲットにしていますか? – mm8
私の.netバージョンは4.0 – gustav
です。参考にしてください。https://stackoverflow.com/help/someone-answers – mm8