2014-11-13 2 views
8

내 페이지에 피벗 항목이 몇 개 있으며 평가판 모드인지 여부에 따라 PivotItem 중 하나를 표시하거나 숨길 필요가 있습니다. XAML 또는 C#에서 직접 PivotItem의 가시성을 설정하면 실제 PivotItem 자체가 아닌 PivotItem 내에있는 항목 만 숨 깁니다. 이것을 어떻게 할 수 있습니까? 테스트에서개별 PivotItem의 가시성을 숨기는 방법

나는 다음과 같은

Page.xaml

<phone:PivotItem x:Name="PivotItem2" Visibility="Collapsed" 
         Header="2"> 
       ... 
</<phone:PivotItem> 

또는

Page.xaml.cs 모두를 시도했습니다

protected override void OnNavigatedTo(NavigationEventArgs e) 
    { 
     base.OnNavigatedTo(e); 

     //Check trial state and set PivotItem 
     if ((Application.Current as App).IsTrial) 
     { 
      PivotItem2.Visibility = Visibility.Collapsed; 
     } 
     else 
     { 
      PivotItem2.Visibility = Visibility.Visible; 
     } 
    } 
+1

PivotItem 삭제를 시도 했습니까? – Romasz

+0

평가판 상태가 아닌데도 표시해야합니다. – Matthew

+0

어쩌면 이렇게 할 수 있습니다. 전체 모드를 준비하십시오. 평가 모드 (예인 경우)가 pivotitem을 제거하면 Page 생성자에서 확인하십시오. – Romasz

답변

13

에만 제거 할 수 있습니다 또는 Pivot.Items 컬렉션을 사용하여 PivotItems를 Pivot에 동적으로 추가하십시오. 당신은 그들을 숨길 수 없습니다. 요구 사항에 따라 다음을 수행 할 수 있습니다.

//Check trial state and set PivotItem 
if ((Application.Current as App).IsTrial) 
{ 
    PivotControl.Items.Remove(PivotControl.Items.Single(p => ((PivotItem)p).Name == "Name_PivotItem")); 
} 
else 
{ 
    PivotControl.Items.Add(PivotControl.Items.Single(p => ((PivotItem)p).Name == "Name_PivotItem")); 
} 
+0

피벗 컨트롤, 인덱스 1에서 두 번째 피벗 항목으로 추가해야하는 경우 어떻게합니까? – Matthew

+0

PivotItem의 'index'속성을 해결해야합니다. –

관련 문제