我有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
未更新?