매우 이상한 문제가 있습니다. 바인딩을 설정하고 바인딩을 다른 속성으로 변경하면 작동하지 않습니다. 이 간단한 예제 FinalTotal 변경UWP : 데이터 바인딩 바꾸기
lblTotal.SetBinding(TextBlock.TextProperty, new Binding() { Path = new PropertyPath("Subtotal"), Source = Order, Mode = BindingMode.OneWay });
lblTotal.SetBinding(TextBlock.TextProperty, new Binding() { Path = new PropertyPath("FinalTotal"), Source = Order, Mode = BindingMode.OneWay });
에서
봐는 lblTotal 텍스트는 는 변경되지 않습니다.
이제 첫 줄을 주석 처리했습니다.
//lblTotal.SetBinding(TextBlock.TextProperty, new Binding() { Path = new PropertyPath("Subtotal"), Source = Order, Mode = BindingMode.OneWay });
lblTotal.SetBinding(TextBlock.TextProperty, new Binding() { Path = new PropertyPath("FinalTotal"), Source = Order, Mode = BindingMode.OneWay });
지금 작업 중 !!!! FinalTotal을 변경하면 lblTotal 텍스트가 변경됩니다! 왜 그런가?
또한 BindingOperations.ClearBinding()은 UWP에서 사용할 수 없습니다. 그래서 빈 바인딩으로 대체하려고했지만 여전히 작동하지 않습니다.
lblTotal.SetBinding(TextBlock.TextProperty, new Binding() { Path = new PropertyPath("Subtotal"), Source = Order, Mode = BindingMode.OneWay });
//remove binding - not sure if this is correct way to remove binding because
//BindingOperations.ClearBinding() isn't available in UWP!
BindingOperations.SetBinding(lblTotal, TextBlock.TextProperty, new Binding());
lblTotal.SetBinding(TextBlock.TextProperty, new Binding() { Path = new PropertyPath("FinalTotal"), Source = Order, Mode = BindingMode.OneWay });
내 질문은 : 1. 어떻게 UWP 바인딩 교체? 2. UWP에서 기존 바인딩을 제거하는 방법 (즉, BindingOperations.ClearBinding())과 동일한 기능을 제거 하시겠습니까? 어떤 도움
덕분에 ...
단지 quess - BindingMode를 TwoWay로 변경할 수 있습니까? – Sasha
안녕 사샤, 나는 그것을 시도했지만 여전히 작동하지 않습니다 : ( – Sam
"소계"에 대한 바인딩 설정 오류가 발생합니다. 출력 창에 바인딩 오류가 표시됩니까? – Sasha