绑定不会随视图的TextBox一起更新

时间:2012-12-17 11:39:00

标签: c# wpf mvvm textbox dependency-properties

我有TextBox

<TextBox DockPanel.Dock="Left" Width="32" Text="{Binding DMinRange, Mode=OneWay}"/>

哪个连接到ViewModel的DMinRange依赖项prop:

        public string DMinRange
        {
            get { return (string)GetValue(DMinRangeProperty); }
            set { SetValue(DMinRangeProperty, value); }
        }

        public static readonly DependencyProperty DMinRangeProperty =
            DependencyProperty.Register("DMinRange", typeof(string), typeof(Spectrum), new UIPropertyMetadata("0"));

并且正在更新(我打印的MessageBox没有显示零,但TextBox仍然显示

依赖关系正在使用此方法进行更新:

public void UpdateRange()
{
    // need to provide some validation
    DMinRange = MinRange.ToString();
    DMaxRange = MaxRange.ToString();
}

我的错误是TextBox未更新?

0 个答案:

没有答案