8. <RelativePanel>
<Rectangle x:Name="BlueRect"
Height="100" Width="200" Fill="Blue" />
<Rectangle x:Name="RedRect"
Height="100" Width="100" Fill="Red"
RelativePanel.Below="BlueRect"
RelativePanel.AlignHorizontalCenterWith="BlueRect" />
</RelativePanel>
Relative Panel
• 다른 Element를 기준으로 상대적 위치 설정
• 다른 Element를 기준으로 상대적 정렬 설정
• 기존 Panel과 같이 AttachedProperty로 설정됨
19. X:Phase rendering
• 기본값 0
• 가능한 적은 단계로 관리
• 연속적일 필요는 없음
<DataTemplate x:DataType="model:Monster">
<Grid Width="200" Height="80">
<TextBlock Text="{x:Bind Name}" />
<TextBlock Text="{x:Bind StarSign}" x:Phase="1"/>
</Grid>
</DataTemplate>
20. deferred loading
• 초기 로드되는 요소 최소화
• 요소가 요구되기 전까지는 loading 되지 않는다
• 요소가 요구되는 상황
1. FindName()
2. GetTemplatedChild() (ControlTemplate 일경우)
3. Storyboard & VisualStates (내부적으로 FindName호출함)
<StackPanel x:Name="AdditionalProductPage" Visibility="Collapsed"
x:DeferLoadStrategy="Lazy">
<!– your lovely XAML goes here-->
</StackPanel>
21. deferred loading
• 경량의 proxy element가 대신 생성됨
• 이벤트는 element가 로딩된 후 등록됨
• Binding 동작도 element가 로딩된 후 완성됨
• {x:Bind} 도 동일
22. 2 Tool
• 비주얼 스튜디오 2015 의 새로운 기능
• 진단도구
• 중단점
• 직접실행창 : LINQ
• peek view
• 라이브 시각적 트리
• 라이브 속성 탐색기
37. 컴파일 바인딩
• compiled binding
• 바인딩 성능 향상 & 기존의 편리함을 유지
• 새로운 데이터 바인딩 원리
• 컴파일타임에 바인딩의 일정작업이 진행됨
• 바인딩식은 컴파일타임에 검증됨
∴
런타임시 부하는 상대적으로 적음
바인딩 선언은 코드로 자동 변환된 후 컴파일 됨
런타임시의 리플렉션 코드 최소화
변환된 코드는 디버깅 가능
44. 컴파일 바인딩
• 이벤트 바인딩
• 적용 가능한 함수 시그니처
• 인자 없음 - void Select()
• 이벤트 인자 타입 - void Select(object sender, RoutedEventArgs e)
• - void Select(object sender, object e)
• 오버로딩은 지원되지 않는다->하나의 메서드만 존재해야 함
• 모든 이벤트에 적용 가능함
• Icommand & EventToCommand 대신 사용 가능함
• - 그러나 특정 인자나 혹은 CanExecute와 같은 기능을 포함하지는 않음
<Button Click=“SelectEmployee">사원 정보 선택</Button>
<Button Click="{x:Bind Employee.Select}">사원 정보 선택</Button>
45. x:Bind
• 컴파일된 바인딩
• 바인딩 표현식은 컴파일시에 검증된다
• Strongly-typed 바인딩
• 리플렉션을 사용하지 않는다
• 페이지 자신의 멤버를 바인딩
• DataContext와는 무관함
• 기본 모드는 OneTime
• 기존의 OneWay, TwoWay 모드도 가능함
• Classic Binding에서는 OneWay가 기본 모드임
• 기타 표준 바인딩 원리 준수
• INotifyPropertyChanged, INotifyCollectionChanged, IObservableVector
46. x:Bind 고려할 점
• MVVM에서 적용?
• View와 ViewModel과의 coupling 문제
• JSON객체 혹은 untyped object일 경우 사용불가
• Classic Binding을 사용
• 스타일에서의 사용
• {x:Bind}은 style에서 setters 로는 사용 불가
• {x:Bind}은 style에 정의된 DataTemplate 에서는 사용가능
47. {Binding} {x:Bind}
•예상 되는 패턴
public sealed partial class CompiledBindingPage : Page
{
public SampleViewModel sViewModel { get; set; }
public CompiledBindingPage()
{
this.InitializeComponent();
this.DataContextChanged += (s, e) =>
{
sViewModel = DataContext as SampleViewModel;
};
}
}