2016-07-01 3 views
0

Я использую разделенный вид для меню в моем проекте. Я разработал следующий код для разработки разделенного вида с моей страницейЗвонок с разбивкой по всему миру

<Grid Background="Gray"> 
     <Grid> 
      <Grid.RowDefinitions> 
       <RowDefinition Height="60"></RowDefinition> 
       <RowDefinition Height="45"></RowDefinition> 
       <RowDefinition Height="*"></RowDefinition> 
      </Grid.RowDefinitions> 

      <Grid Grid.Row="0"> 
       <Image Source="Source of the image" HorizontalAlignment="Center" Margin="1 5 0 0"></Image> 
      </Grid> 

      <Grid Grid.Row="1"> 
       <Grid.ColumnDefinitions> 
        <ColumnDefinition Width="50"></ColumnDefinition> 
        <ColumnDefinition Width="*"></ColumnDefinition> 
       </Grid.ColumnDefinitions> 
       <Grid Grid.Column="0"> 
        <Button x:Name="HamburgerButton" FontFamily="Segoe MDL2 Assets" Content="&#xE700;" 
          Width="60" Height="60" Background="Transparent" Margin="-10 -20 0 0" 
          Click="HamburgerButton_Click"/> 
       </Grid> 
       <Grid Grid.Column="1"> 
        <TextBlock Text="Heading" HorizontalAlignment="Center" FontSize="30" 
          Margin="-35 0 0 0" Foreground="White"></TextBlock> 
       </Grid> 
      </Grid> 

      <Grid Grid.Row="2" x:Name="ArticlesGrid" Visibility="Collapsed"> 
       <SplitView x:Name="MySplitView" DisplayMode="CompactOverlay" IsPaneOpen="False" 
       CompactPaneLength="0" OpenPaneLength="220"> 
        <SplitView.Pane> 
         <ListView x:Name="menuBindList" Background="Gray"> 
          <ListView.ItemTemplate> 
           <DataTemplate> 
            <StackPanel> 
             <StackPanel Orientation="Horizontal" Tag="{Binding SectionName}"> 
              <!--<Button x:Name="MenuButton1" FontFamily="Segoe MDL2 Assets" Content="&#xE825;" 
            Width="50" Height="50" Background="Transparent" Margin="-10 0 0 0"/>--> 
              <TextBlock Text="{Binding TitleofAccess}" 
                Tag="{Binding SectionName}" FontSize="18" 
                VerticalAlignment="Center" Tapped="MenuTextBlock_Tapped" /> 
             </StackPanel> 
            </StackPanel> 
           </DataTemplate> 
          </ListView.ItemTemplate> 
         </ListView> 
        </SplitView.Pane> 
        <SplitView.Content> 
         <ScrollViewer Name="articlesScroll"> 
          <Pivot DataContext="{StaticResource ViewModel}" x:Name="pivot" 
            HeaderTemplate="{StaticResource headerTemplate}" 
            ItemTemplate="{StaticResource pivotTemplate}" ItemsSource="{Binding Feeds}" Margin="0,-10,0,10"> 
          </Pivot> 
         </ScrollViewer> 
        </SplitView.Content> 
       </SplitView> 
      </Grid> 
     </Grid>   
    </Grid> 

Он дает желаемый результат работы шахты. Но я использую это разделенное представление на каждой странице. Как я могу использовать разделенный вид по всему миру для каждой страницы. Пожалуйста, дайте несколько примеров для достижения этого

+0

Поместите его в стиль корневой рамки. – Bells

+0

Можете ли вы поделиться примерами кода – Anbarasi

+0

, не используйте теги windows-phone-8.1, пожалуйста. –

ответ

0

Вы можете поместить SplitView в стиль корневой рамки.

<Style x:Key="NewFrameStyle" TargetType="Frame">  
      <Setter Property="Template"> 
       <Setter.Value> 
        <ControlTemplate TargetType="Frame"> 
         <Grid Background="Gray"> 
          <SplitView> 
           <SplitView.Pane> 
            ... 
           </SplitView.Pane> 
           <SplitView.Content> 
            ... 
           </SplitView.Content>         
         </Grid> 
       </Setter.Value> 
      </Setter> 
</Style> 


protected override void OnLaunched(LaunchActivatedEventArgs e) 
{ 
     ... 
     Frame rootFrame = Window.Current.Content as Frame; 
     ... 
     rootFrame.Style = this.Resources["NewFrameStyle"] as Style; 
} 
Смежные вопросы