我有一个 TextBox,它绑定到一个字符串属性:
文本框:
<TextBox x:Name="SearchBox"
Text="{Binding SearchText, Source={StaticResource SearchEngine}, Mode=TwoWay}"
</TextBox>
以及绑定到的类:
public class SearchEngine : ViewModelBase
{
private string _searchText = string.Empty;
public SearchEngine() {
Console.Out.WriteLine("this = {0}", this);
SearchText = "Search";
}
public string SearchText
{
get { return _searchText; }
set
{
if (_searchText != value)
{
_searchText = value;
Console.Out.WriteLine("AAAAAAAAAAAA: " + value);
NotifyPropertyChanged();
}
}
}
}
问题是当我输入文本框时,SearchText
没有更新。