2014-05-16 2 views
0

현재 선택된 HubSection을 얻을 수 있도록 Windows 8.1/Windows Phone 8.1의 허브 컨트롤에 바인딩 할 수있는 속성이 있습니까? 일반적으로 TabControl의 경우 SelectedIndex 속성을 설정합니다. 그러나 이것은 Hub 제어에 대해 존재하지 않는 것 같습니다.Windows Phone 8.1/Windows 8.1의 현재 보이는 허브 섹션

지금까지 내가 발견 할 수있는 유일한 속성은 SectionsInView 속성입니다. 그러나 읽기 전용이며 DataBinding을 통해 바인딩 할 수 없습니다.

enter image description here

+0

어떻게 결합하려고 (알려) 테스트? 그것은 벡터입니다. 그리고 TextBloc에서 데이터를 바인딩 할 수 있음에도 불구하고 – Kamen

답변

1

이 처리 할 수있는 방법 그러나 대한 기본 재산이 없다는 것을 수치를 찾아보십시오.

그래서 내가 무슨 짓을 :

 private int CurrentSectionIndex = 0; 
     private HubSection CurrentSection 
     { 
      get { return this.Hub.SectionsInView[CurrentSectionIndex]; } 
     } 

     //Retrieve the ScrollViewer of the Hub control and handle the ViewChanged event of this ScrollViewer 
     public Page() 
     { 
      ScrollViewer sv = ControlHelper.GetChild<ScrollViewer>(this.Hub); 
      sv.ViewChanged += sv_ViewChanged; 
     } 
     //In the ViewChanged event handler body then calculate the index relative to the horizontal offset (means current position) of the ScrollViewer 
     void sv_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e) 
     { 
      if(!e.IsIntermediate) 
      { 
       double ho = ControlHelper.GetChild<ScrollViewer>(this.Hub).HorizontalOffset; 

       if (ho >= CurrentSection.ActualWidth - (this.ActualWidth - CurrentSection.ActualWidth)) 
       { 
        CurrentSectionIndex = (int)((ho + (this.ActualWidth - CurrentSection.ActualWidth))/CurrentSection.ActualWidth); 
       } 
      } 
     } 

가 작동하는 것 같다하지만 여전히

+0

ControlHelper에 대한 언급은 내가 한 클래스이지만, 웹에서 유형별로 자식 컨트롤을 찾는 다양한 방법을 찾을 수 있습니다. – Shog

관련 문제