我有一些面板两个控件:文本框和组合框:
<TextBox Text="{Binding ShapeName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" />
<ComboBox SelectedItem="{Binding ActiveStageViewModel, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" />
我需要强制IDataErrorInfo的验证的文本框,当我选择的组合框的东西。 怎么做?
从视图模型的代码:
string IDataErrorInfo.this[string propertyName]
{
get
{
var error = string.Empty;
if (propertyName == Expression.GetPropertyName(() => ActiveStageViewModel))
{
// TODO: Add functionality to force ShapeName property validation
return error;
}
if (propertyName == Expression.GetPropertyName(() => ShapeName))
{
error = ValidateShapeName();
}
TooltipMessage = error;
return error;
}
}