2010-03-30 3 views
1

내 페이지의 탐색 단추 대신 탐색 경로를 사용하는 코드를 발견했습니다. 이 코드는 페이지를 시작으로 설정하면 완벽하게 작동합니다. 내 문제는 시작으로 프레임 컨트롤이있는 창을 가져야하며이 때문에 이동 경로가 전혀 표시되지 않는 것입니다. 나는 내 스타일에 뭔가 빠져있는 것 같다. NavigationWindow로 사용되는 유형이지만 프레임으로 변경하여 실제 솔루션을 시도했습니다.WPF 탐색 페이지 Breadcrumb

<Style TargetType="Frame" x:Key="{x:Type Frame}"> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="Frame"> 
       <Grid Background="Transparent"> 
        <Grid.RowDefinitions> 
         <RowDefinition Height="50"/> 
         <RowDefinition Height="50"/> 
         <RowDefinition Height="*"/> 
        </Grid.RowDefinitions> 

        <ItemsControl ItemsSource="{Binding 
         RelativeSource={RelativeSource AncestorType={x:Type Frame}}, 
         Path=BackStack}"> 

         <!--Force the ItemsContol to use a wrap panel as Items host--> 
         <ItemsControl.ItemsPanel> 
          <ItemsPanelTemplate> 
           <local:InverseWrapPanel KeyboardNavigation.TabNavigation="Cycle" 
              KeyboardNavigation.DirectionalNavigation="Cycle"/> 
          </ItemsPanelTemplate> 
         </ItemsControl.ItemsPanel> 

         <ItemsControl.ItemTemplate> 
          <DataTemplate> 
           <Button Command="NavigationCommands.NavigateJournal" 
             CommandParameter="{Binding RelativeSource={RelativeSource Self}}" 
             Content="{Binding Name}"> 
            <Button.Template> 
             <ControlTemplate TargetType="Button"> 
              <WrapPanel> 
               <TextBlock Name="text1" FontWeight="Bold" Text="{TemplateBinding Content}"/> 
               <TextBlock Name="text2" FontWeight="Bold" Text=">>" Margin="2,0,0,0"/> 
              </WrapPanel> 
              <ControlTemplate.Triggers> 
               <Trigger Property="IsMouseOver" Value="True"> 
                <Setter TargetName="text1" Property="Foreground" Value="Blue"/> 
                <Setter TargetName="text2" Property="Foreground" Value="Blue"/> 
               </Trigger> 
              </ControlTemplate.Triggers> 
             </ControlTemplate> 
            </Button.Template> 
           </Button> 
          </DataTemplate> 
         </ItemsControl.ItemTemplate> 

        </ItemsControl> 

        <AdornerDecorator Grid.Row="2"> 
         <ContentPresenter Name="PART_NavWinCP" ClipToBounds="true"/> 
        </AdornerDecorator> 
       </Grid> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 

답변

1

변경 :

<ItemsControl ItemsSource="{Binding 
         RelativeSource={RelativeSource TemplatedParent}, 
         Path=BackStack}"> 

과 그 작동합니다 :

<ItemsControl ItemsSource="{Binding 
         RelativeSource={RelativeSource AncestorType={x:Type Frame}}, 
         Path=BackStack}"> 

합니다.