C#/WPF

[WPF] Data Binding

딸기우유중독 2022. 7. 6. 11:43

  • UI와 Data를 동기화시켜주는 기술
  • 앱이 UI를 표현하고 Data와 상호작용하는 것을 단순화
  • 컨트롤(Control)의 Property와 내가 지정한 객체의 Property를 연결 (Target ↔ Source)
  • Bingding을 위해 BindingContext 속성이 반드시 소스객체를 참조
  • XAML에서 Binding 마크업을 사용해 설정

  • Binding 마크업은 Path, Mode 속성이 있음
  • Path : 바인딩하고자 하는 원본객체의 속성명
  • Mode : 속성 값의 변화가 영향을 줄 방향
    • OneWay 소스에서 타깃으로만 변경사항이 반영 (Default)
    • TwoWay 양방향으로 적용. 소스와 타깃객체가 항상 동기화
    • OnwWayToSource 타깃에서 소스로만 변경사항이 반영. 주로, 읽기전용의 바인딩 속성에 사용.
    • OneTime 생성자에서 초기화될 때, 한 번만 소스에서 타깃으로 반영
  • PropertyChanged를 이용해 속성 변경에 이벤트 발생
 

[C#] WPF - Data Binding

데이터가 UI 에 바인딩 되는 방식의 이해

mindflip.github.io


What does "{Binding Path=.}" mean in WPF binding?

I found this WPF Binding CheatSheet a few months back and find it very useful, especially for anyone learning WPF. There are some spelling mistakes within it, but it is still quite good.

Here is a small excerpt (which is supposed to have tabular formatting):

Basic Binding
{Binding} Bind to current DataContext.
{Binding Name} Bind to the “Name” property of the current DataContext.
{Binding Name.Length} Bind to the Length property of the object in the Name property of the current DataContext.
{Binding ElementName=SomeTextBox, Path=Text} Bind to the “Text” property of the element XAML element with name=”SomeTextBox” or x:Name=”SomeTextBox”.

https://stackoverflow.com/questions/1066262/what-does-binding-path-mean-in-wpf-binding

 

What does "{Binding Path=.}" mean in WPF binding?

What does {Binding Path=.} mean in a WPF binding? I see some people use it, but couldn't find any explanation. Are there any other special symbols in binding syntax (other than {Binding /})?

stackoverflow.com

 

728x90