사용자 도구

사이트 도구


sdk:wpf:데이터-바인딩

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판이전 판
다음 판
이전 판
sdk:wpf:데이터-바인딩 [2013/12/26 18:04] kieunssdk:wpf:데이터-바인딩 [2024/04/23 22:44] (현재) – 바깥 편집 127.0.0.1
줄 1: 줄 1:
 +
 +쉬운 듯<sup>10%</sup> 복잡한듯<sup>90%</sup>
 +
 +====== xaml 헤더 ======
 +
 +는 거의 같다. 
 +
 +<code xml>
 +<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 +        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 +        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
 +        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 +        
 +        mc:Ignorable="d"
 +        
 +        x:Class="네임스페이스.해당 윈도우 클래스"
 +        xmlns:local="clr-namespace:네임스페이스"
 +        Title="MainWindow" Height="400" Width="525" MinWidth="525" MinHeight="400"
 +        WindowStartupLocation='CenterScreen'
 +        >
 +</code>
 +
 +| %%x:Class="..."%% : 현재 앱의 네임스페이스와 윈도우 클래스 이름 |
 +| %%xmlns:local="clr-namespace:네임스페이스"%% : local 은 임의로 정한 이름. 바꿔 써도 된다. |
 +
 +
 +====== 데이터를 바인딩 할때 연결할 것들 ======
 +
 +
 +^ DataContext : 코드 또는 xaml에서 연결할 데이터(프로퍼티들)가 어디 있는지 명시 해야 한다. ^
 +| <code csharp>
 +// MainWindow.xaml.cs 파일이고 MainWindow.xaml과 연결되는 거라면
 +public class MainWindow {
 +  public MainWindow() {
 +    this.DataContext = this;
 +  }
 +}
 +</code> |
 +
 +DataContext를 MainWindow로 설정 했으므로, MainWindow의 프로퍼티는 **Path**키워드로 설정 가능하다.
 +
 +<code xml>
 +<TextBox x:Name="TargetFolderPath" Text="{Binding Path=SelectedPath}" />
 +<!--
 +    x:Name 은 이 컨트롤의 이름을 설정하는 것. 코드에서 TargetFolderPath 를 쓸 수 있다.
 +    SelectedPath 는 MainWindow의 프로퍼티. 
 +-->
 +</code>
 +
 +
 +===== Path 와 XPath =====
 +
 +  * Path  로 쓸 수 있는 것은 오브젝트의 프로퍼티.
 +  * XPath 로 쓸 수 있는 것은 xml 의 엘리먼트 요소.
 +
 +
 +
 +
 +
 +====== 외부 참조 ======
 +
 +  * [[sdk:wpf:데이터_바인딩_msdn|msdn에서 읽은 것 정리한 것]]
 +
 +
 +
 +
 +
 +
 +