2016-07-26 316 views
1

我在同一个数据透视项目中有多个部分项目模板在Windows 8.1手机8.1中动态绑定项目模板

下面是枢轴

<Page 
    x:Class="Namespace.Page" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="using:Namespace" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:ViewModels="Namespace.ViewModels" 
    xmlns:q42controls="using:Q42.WinRT.Controls" 
    mc:Ignorable="d"> 

    <Page.Resources> 
     <ViewModels:ViewModel x:Key="ViewModel" /> 
     <DataTemplate x:Key="headerTemplate"> 
      <TextBlock Text="{Binding Title}" FontSize="16"/> 
     </DataTemplate> 
     <DataTemplate x:Key="pivotTemplate"> 
      <ListView x:Name="listView" Background="White" ItemsSource="{Binding Articles}" 
         HorizontalAlignment="Left" Margin="-25 0 -25 0" SelectionChanged="getIndex"> 
       <ListView.ItemTemplate> 
        <DataTemplate> 
         <StackPanel Tapped="StackPanel_Tapped"> 
          <Grid> 
           <Grid.Background> 
            <ImageBrush AlignmentX="Center" AlignmentY="Center" ImageSource="Assets/PlaceHolder.jpg"></ImageBrush> 
           </Grid.Background> 
           <Image x:Name="ArticleImage" q42controls:ImageExtensions.CacheUri="{Binding ImageURL}"></Image>         
          </Grid> 
          <StackPanel> 
           <TextBlock x:Name="HeadLine" Text="{Binding HeadLine}" 
               Margin="10 5 10 -5" TextWrapping="Wrap" 
               FontSize="20" 
               FontFamily="{StaticResource HeadlineCommonFamiy}" 
               Pivot.SlideInAnimationGroup="GroupTwo" 
               FontWeight="Bold" TextTrimming="CharacterEllipsis" Height="63"/> 

           <TextBlock Text="{Binding Abstract}" TextWrapping="Wrap" FontSize="15" 
            Pivot.SlideInAnimationGroup="GroupTwo" Margin="10 5 0 10" 
              FontFamily="{StaticResource AbstractCommonFamily}"/> 
          </StackPanel> 
         </StackPanel> 
        </DataTemplate> 
       </ListView.ItemTemplate> 
      </ListView> 
     </DataTemplate> 
    </Page.Resources> 

    <Page.BottomAppBar> 
     <CommandBar Foreground="Black" ClosedDisplayMode="Minimal" Background="White"> 
      <CommandBar.PrimaryCommands> 
       <AppBarButton x:Uid="Refresh" Icon="Refresh" Label="Refresh" Tapped="RefreshButton_Tapped"/> 
      </CommandBar.PrimaryCommands> 
      <CommandBar.SecondaryCommands> 
       <AppBarButton x:Uid="Favourites" Icon="Favorite" Label="Favourites" Tapped="Favourites_Tapped"/> 
       <AppBarButton x:Uid="Settings" Icon="Setting" Label="Settings" Tapped="Settings_Tapped"/> 
      </CommandBar.SecondaryCommands> 
     </CommandBar> 
    </Page.BottomAppBar> 

    <Grid Style="{StaticResource MyGridStyle}"> 
     <Grid x:Name="LoadingGrid" Visibility="Visible"> 
      <ProgressRing x:Name="progressRing" IsActive="True" Foreground="White" HorizontalAlignment="Center" Width="60" 
          Height="50" VerticalAlignment="Center" Margin="0 20 0 0"></ProgressRing> 
     </Grid> 

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

      <Grid Grid.Row="0"> 
       <Image Source="Assets/_logo.png" 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" Foreground="White"/> 
       </Grid> 
       <Grid Grid.Column="1"> 
        <TextBlock Text="சினிமா" HorizontalAlignment="Center" FontSize="30" 
          Margin="-50 0 0 0" Foreground="White"></TextBlock> 
       </Grid> 
      </Grid> 

      <Grid Grid.Row="2" x:Name="galleryGrid" Visibility="Collapsed"> 
       <SplitView x:Name="MySplitView" DisplayMode="CompactOverlay" IsPaneOpen="False" 
          CompactPaneLength="0" OpenPaneLength="220"> 
        <SplitView.Pane> 
         <ListView x:Name="menuBindList" Style="{StaticResource MyListViewStyle}"> 
          <ListView.ItemTemplate> 
           <DataTemplate> 
            <StackPanel> 
             <StackPanel Orientation="Horizontal" Tag="{Binding SectionName}"> 
              <TextBlock Text="{Binding TitleofAccess}" 
                Tag="{Binding SectionName}" FontSize="18" 
                VerticalAlignment="Center" Foreground="White" Tapped="MenuTextBlock_Tapped" /> 
             </StackPanel> 
            </StackPanel> 
           </DataTemplate> 
          </ListView.ItemTemplate> 
         </ListView> 
        </SplitView.Pane> 
        <SplitView.Content> 
         <ScrollViewer Name="cinemaScroll"> 
          <Pivot DataContext="{StaticResource ViewModel}" x:Name="galleryPivot" 
            HeaderTemplate="{StaticResource headerTemplate}" 
            ItemTemplate="{StaticResource pivotTemplate}" ItemsSource="{Binding Feeds}" 
            Margin="0,-10,0,10" SelectionChanged="galleryPivot_SelectionChanged"> 

           <Pivot.Resources> 
            <Style TargetType="PivotHeaderItem"> 
             <Setter Property="CharacterSpacing" Value="{ThemeResource PivotHeaderItemCharacterSpacing}" /> 
             <Setter Property="Background" Value="Transparent" /> 
             <Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseMediumBrush}" /> 
             <Setter Property="Padding" Value="{ThemeResource PivotHeaderItemMargin}" /> 

             <Setter Property="VerticalContentAlignment" Value="Center" /> 
             <Setter Property="IsTabStop" Value="False" /> 
             <Setter Property="RequestedTheme" Value="Dark" /> 
             <Setter Property="Template"> 
              <Setter.Value> 
               <ControlTemplate TargetType="PivotHeaderItem"> 
                <Grid 
         x:Name="Grid" 
         Background="{TemplateBinding Background}"> 
                 <Grid.Resources> 
                  <Style x:Key="BaseContentPresenterStyle" TargetType="ContentPresenter"> 
                   <Setter Property="FontFamily" Value="Segoe UI"/> 
                   <Setter Property="FontWeight" Value="SemiBold"/> 
                   <Setter Property="FontSize" Value="15"/> 
                   <Setter Property="TextWrapping" Value="Wrap"/> 
                   <Setter Property="LineStackingStrategy" Value="MaxHeight"/> 
                   <Setter Property="TextLineBounds" Value="Full"/> 
                   <Setter Property="OpticalMarginAlignment" Value="TrimSideBearings"/> 
                  </Style> 
                  <Style x:Key="BodyContentPresenterStyle" TargetType="ContentPresenter" BasedOn="{StaticResource BaseContentPresenterStyle}"> 
                   <Setter Property="FontFamily" Value="{ThemeResource PivotHeaderItemFontFamily}" /> 
                   <Setter Property="FontWeight" Value="{ThemeResource PivotHeaderItemThemeFontWeight}"/> 
                   <Setter Property="FontSize" Value="{ThemeResource PivotHeaderItemFontSize}"/> 
                  </Style> 
                 </Grid.Resources> 
                 <VisualStateManager.VisualStateGroups> 
                  <VisualStateGroup x:Name="SelectionStates"> 
                   <VisualStateGroup.Transitions> 
                    <VisualTransition From="Unselected" To="UnselectedLocked" GeneratedDuration="0:0:0.33" /> 
                    <VisualTransition From="UnselectedLocked" To="Unselected" GeneratedDuration="0:0:0.33" /> 
                   </VisualStateGroup.Transitions> 
                   <VisualState x:Name="Disabled"> 
                    <Storyboard> 
                     <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" 
                     Storyboard.TargetProperty="Foreground" > 
                      <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledBaseMediumLowBrush}" /> 
                     </ObjectAnimationUsingKeyFrames> 
                    </Storyboard> 
                   </VisualState> 
                   <VisualState x:Name="Unselected" /> 
                   <VisualState x:Name="UnselectedLocked"> 
                    <Storyboard> 
                     <DoubleAnimation Storyboard.TargetName="ContentPresenterTranslateTransform" 
                 Storyboard.TargetProperty="X" 
                 Duration="0" To="{ThemeResource PivotHeaderItemLockedTranslation}" /> 
                     <DoubleAnimation Storyboard.TargetName="ContentPresenter" 
                 Storyboard.TargetProperty="(UIElement.Opacity)" 
                 Duration="0" To="0" /> 
                    </Storyboard> 
                   </VisualState> 
                   <VisualState x:Name="Selected"> 
                    <Storyboard> 
                     <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" 
                     Storyboard.TargetProperty="Foreground" > 
                      <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" /> 
                     </ObjectAnimationUsingKeyFrames> 
                     <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Grid" 
                     Storyboard.TargetProperty="Background" > 
                      <DiscreteObjectKeyFrame KeyTime="0" Value="#FF42424C" /> 
                     </ObjectAnimationUsingKeyFrames> 
                    </Storyboard> 
                   </VisualState> 
                   <VisualState x:Name="UnselectedPointerOver"> 
                    <Storyboard> 
                     <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" 
                     Storyboard.TargetProperty="Foreground" > 
                      <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltBaseMediumHighBrush}" /> 
                     </ObjectAnimationUsingKeyFrames> 
                     <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Grid" 
                     Storyboard.TargetProperty="Background" > 
                      <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightTransparentBrush}" /> 
                     </ObjectAnimationUsingKeyFrames> 
                    </Storyboard> 
                   </VisualState> 
                   <VisualState x:Name="SelectedPointerOver"> 
                    <Storyboard> 
                     <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" 
                     Storyboard.TargetProperty="Foreground" > 
                      <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltBaseMediumHighBrush}" /> 
                     </ObjectAnimationUsingKeyFrames> 
                     <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Grid" 
                     Storyboard.TargetProperty="Background" > 
                      <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightTransparentBrush}" /> 
                     </ObjectAnimationUsingKeyFrames> 
                    </Storyboard> 
                   </VisualState> 
                   <VisualState x:Name="UnselectedPressed"> 
                    <Storyboard> 
                     <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" 
                     Storyboard.TargetProperty="Foreground" > 
                      <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltBaseMediumHighBrush}" /> 
                     </ObjectAnimationUsingKeyFrames> 
                     <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Grid" 
                     Storyboard.TargetProperty="Background" > 
                      <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightTransparentBrush}" /> 
                     </ObjectAnimationUsingKeyFrames> 
                    </Storyboard> 
                   </VisualState> 
                   <VisualState x:Name="SelectedPressed"> 
                    <Storyboard> 
                     <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" 
                     Storyboard.TargetProperty="Foreground" > 
                      <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltBaseMediumHighBrush}" /> 
                     </ObjectAnimationUsingKeyFrames> 
                     <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Grid" 
                     Storyboard.TargetProperty="Background" > 
                      <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightTransparentBrush}" /> 
                     </ObjectAnimationUsingKeyFrames> 
                    </Storyboard> 
                   </VisualState> 
                  </VisualStateGroup> 
                 </VisualStateManager.VisualStateGroups> 
                 <ContentPresenter 
          x:Name="ContentPresenter" 
          Content="{TemplateBinding Content}" 
          ContentTemplate="{TemplateBinding ContentTemplate}" 
          Margin="{TemplateBinding Padding}" 
          FontSize="{TemplateBinding FontSize}" 
          FontFamily="{TemplateBinding FontFamily}" 
          FontWeight="{TemplateBinding FontWeight}" 
          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"> 
                  <ContentPresenter.RenderTransform> 
                   <TranslateTransform x:Name="ContentPresenterTranslateTransform" /> 
                  </ContentPresenter.RenderTransform> 
                 </ContentPresenter> 
                </Grid> 
               </ControlTemplate> 
              </Setter.Value> 
             </Setter> 
            </Style> 
           </Pivot.Resources> 
          </Pivot> 
         </ScrollViewer> 
        </SplitView.Content> 
       </SplitView> 
      </Grid> 
     </Grid> 
    </Grid> 
</Page> 

我需要动态改变项模板特定部分的我的XAML的一部分。我怎样才能做到这一点。该部分将包含图像,我们需要更改整个项目模板,并在那里我们在枢轴内部进行重定向。如何获得场景。

下面是形象设计需要

项目的第一个列表绑定的特定部位如下面 enter image description here

同样它包含的产品清单。在每个部分中的自攻 重定向到下面 enter image description here

在攻丝单个图像的带我们到

enter image description here

攻牙将重定向到以下部分 enter image description here

上述方法将在一个枢纽项目中进行。这是可能的。如果有可能如何实现这一点。请人指导我解决这个

+0

请指定itemTemplate更改的触发器是什么基于 – Jerin

+0

您好jerin感谢您的回复。在枢轴选择更改中,我必须更改项目模板 – Anbarasi

+0

更改透视选择更改时的ItemTemplate。由于默认情况下只有一个pivot可见,所以最好有不同的ItemTemplate pivot。反正看看我的答案。它可能会帮助你。 – Jerin

回答

0

按我的理解会建议一些方法,可以在其中实现这个

<Pivot >... 
     <PivotItem x:Uid="OVERVIEW" Header="" Margin="0"> 
         <Grid>... 
         </Grid> 
     </PivotItem>....... 
    </Pivot> 
  • 将指定的ItemTemplate为支点物品内部的具体支点。如果变化是特定于每个枢轴

  • 另一种方法是使用此Link可以代替,甚至使用转换器,并根据您的数据可以使网格可见不可见等,但你需要确定你的触发器,更改的ItemTemplate基于。