있습니다윈도우 스토어 나는 윈도우 스토어 프로젝트를 바인딩 문제
다음과 같이 내 바인딩class MyModel
{
private int _testVar;
public int TestVariable
{
get { return _testVar; }
set
{
_testVar = value;
NotifyPropertyChanged("TestVariable");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string property)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(property));
}
}
은 다음과 같습니다
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<TextBlock Text="{Binding Path=TestVariable}" />
<Button Click="Button_Click_1"></Button>
</Grid>
그리고 뒤에있는 코드 :이로
MyModel thisModel = new MyModel();
public MainPage()
{
this.InitializeComponent();
thisModel.TestVariable = 0;
DataContext = thisModel;
}
을 포인트, 바인딩은 내가 0을 보여주는 텍스트 블록을 얻는 것처럼 보입니다. 그러나, 다음과 같이 버튼 클릭 이벤트를 처리 할 때 :
private void Button_Click_1(object sender, RoutedEventArgs e)
{
thisModel.TestVariable++;
}
숫자가 증가하지 않습니다. 내가 여기서 무엇을 놓치고 있니?
내가 그것을 놓쳤다 고 생각할 수 없다! –