Index not working with pivot on first navigate

A place for App developers to hang out / post
Post Reply
brianlich

Posts: 34
Joined: Wed Jun 08, 2011 1:49 am
Location:

HTPC Specs: Show details

Index not working with pivot on first navigate

#1

Post by brianlich » Wed Dec 04, 2013 10:35 pm

I'm using the PivotControl sample from MCML samples (http://mcml.codeplex.com/) and noticed some weirdness.

The first time I navigate into a pivot, hit the up arrow key, it navigates to the second item instead of the first. If I try it again, it goes back to the right spot in the pivot heading. Also, if I add more than one item (for example, I add three images to the repeater) and arrow over to another item, it picks a different pivot item when I hit the up arrow. It seems like the index is using the position in the repeater (and not the ChosenIndex) the first time I try to change the pivot.

Has anybody seen this before? Is there something I can modify from the PivotControl from MCML samples that will fix it?

sccrgoalie1

Posts: 317
Joined: Fri Jul 08, 2011 5:52 pm
Location:

HTPC Specs: Show details

#2

Post by sccrgoalie1 » Thu Dec 05, 2013 5:13 pm

brianlich wrote:I'm using the PivotControl sample from MCML samples (http://mcml.codeplex.com/) and noticed some weirdness.

The first time I navigate into a pivot, hit the up arrow key, it navigates to the second item instead of the first. If I try it again, it goes back to the right spot in the pivot heading. Also, if I add more than one item (for example, I add three images to the repeater) and arrow over to another item, it picks a different pivot item when I hit the up arrow. It seems like the index is using the position in the repeater (and not the ChosenIndex) the first time I try to change the pivot.

Has anybody seen this before? Is there something I can modify from the PivotControl from MCML samples that will fix it?
I must have had some kind of problem with it because I have a copy of it in my solution, but I ended up using this

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>
<Mcml xmlns="http://schemas.microsoft.com/2006/mcml" 	    
      xmlns:cor="assembly://MSCorLib/System"       
      xmlns:s="resx://SharedGuidePotato/SharedGuidePotato.Resources/Styles"  
      xmlns:anim="resx://SharedGuidePotato/SharedGuidePotato.Resources/Animations"
      xmlns:pvtitem="resx://SharedGuidePotato/SharedGuidePotato.Resources/PivotItem"
      xmlns:me="Me">
  <UI Name="Pivot">
    <Properties>
      <Choice Name="Model" Choice="$Required"/>
      <Font Name="Font" Font="font://s:Segoe32"/>
      <Font Name="FocusFont" Font="font://s:Segoe36"/>
      <Color Name="Color" Color="color://s:DetailsSlideNonFocusColor"/>
      <Color Name="FocusColor" Color="color://s:DetailsSlideFocusColor"/>
    </Properties>
    <Locals>
      <ScrollingHandler Name="ScrollingHandler" HandlerStage="Bubbled" />
      <!--<ScrollingData Name="ScrollingData" LockedPosition="0.1" />-->
      <ScrollingData Name="ScrollingData" />
      <!--<Choice Name="Model">
        <Options>
          <cor:String String="Synopsis"/>
          <cor:String String="Other Showings"/>
          <cor:String String="Cast + Crew"/>
        </Options>
      </Choice>-->

    </Locals>
    <Rules>
      <Binding Source="[Model.Options]" Target ="[ButtonRepeater.Source]" />
      <Default Target="[ScrollingHandler.ScrollingData]" Value="[ScrollingData]" />
      <Default Target="[ScrollingData.Repeater]" Value="[ButtonRepeater]" />
      <Rule ConditionLogicalOp="And">
        <Conditions>
          <Equality Source="[Input.DeepMouseFocus]" Value="true"/>
          <Equality Source="[Input.DeepKeyFocus]" Value="false"/>
          <Equality Source="[Model.Description]" Value=""/>
        </Conditions>
        <Actions>
          <Set Target="[Model.Description]" Value="Active"/>
          <PlayAnimation Animation="animation://anim:PivotItemFocusOn" Target="[Scroller]" />
        </Actions>
      </Rule>
      <Rule ConditionLogicalOp="And">
        <Conditions>
          <Equality Source="[Input.DeepMouseFocus]" Value="false"/>
          <Equality Source="[Input.DeepKeyFocus]" Value="true"/>
          <Equality Source="[Model.Description]" Value=""/>
        </Conditions>
        <Actions>
          <Set Target="[Model.Description]" Value="Active"/>
          <PlayAnimation Animation="animation://anim:PivotItemFocusOn" Target="[Scroller]" />
        </Actions>
      </Rule>
      <Rule ConditionLogicalOp="And">
        <Conditions>
          <Equality Source="[Input.DeepMouseFocus]" Value="false"/>
          <Equality Source="[Input.DeepKeyFocus]" Value="false"/>
        </Conditions>
        <Actions>
          <Set Target="[Model.Description]" Value=""/>
          <PlayAnimation Animation="animation://anim:PivotItemFocusOff" Target="[Scroller]" />
        </Actions>
      </Rule>
    </Rules>
    <Content>
      <Scroller Name="Scroller"                 
                Orientation="Horizontal"                 
                FocusPadding="100"                 
                Navigation="PreferFocusOrder,RememberFocus"                 
                ScrollingData="[ScrollingData]"                 
                CenterPointPercent="0.75,0.5,0.5"
                
                Scale="0.9,0.9,0.9">
        <Children>
          <Repeater Source="[Model.Options]" Layout="HorizontalFlow" Name="ButtonRepeater" Navigation="WrapHorizontal">
            <Animations>
              <Animation Animation="animation://anim:ScrollerMoveItemSmooth"/>
            </Animations>
            <Layout>
              <FlowLayout Repeat="Never" RepeatGap="100,0" Spacing="30,0" ItemAlignment="Near" />
            </Layout>
            <Content>
              <pvtitem:PivotItem Name ="PivotItem" Label="[RepeatedItem.ToString]"                             
                            Index="[RepeatedItemIndex]"                             
                            Model="[Model]"                           
                            Font="[Font]"                             
                            FocusFont="[FocusFont]"                             
                            Color="[Color]"
                            FocusColor="[FocusColor]"/>

            </Content>
          </Repeater>
        </Children>
      </Scroller>
    </Content>
  </UI>
</Mcml>

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>
<Mcml xmlns="http://schemas.microsoft.com/2006/mcml" 	    
      xmlns:cor="assembly://MSCorLib/System"
      xmlns:anim="resx://SharedGuidePotato/SharedGuidePotato.Resources/Animations"
      xmlns:s="resx://SharedGuidePotato/SharedGuidePotato.Resources/Styles"
      xmlns:me="Me">
  <UI Name="PivotItem">
    <Properties>
      <Font Name="Font" FontSize="12"/>
      <Font Name="FocusFont" FontSize="16"/>
      <Color Name="Color"/>
      <Color Name="FocusColor"/>
      <cor:String Name="Label" cor:String="$Required"/>
      <Choice Name="Model" Choice="$Required"/>
      <Index Name="Index" Index="$Required"/>
    </Properties>
    <Rules>
      <Default Target="[Input.KeyInteractive]" Value="true"/>
      <Default Target="[Input.KeyFocusOnMouseEnter]" Value="false"/>
      <Rule ConditionLogicalOp="Or">
        <Conditions>
          <Equality Source="[Input.MouseFocus]" Value="true"/>
          <Equality Source="[Input.KeyFocus]" Value="true"/>
        </Conditions>
        <Actions>
          <Set Target="[Name.Font]" Value="[FocusFont]" />
          <Set Target="[Name.Color]" Value="[FocusColor]"/>
          <!--<Set Target="[ArrowLeft.Content]" Value="image://me:PivotArrowLeft"/>
          <Set Target="[ArrowRight.Content]" Value="image://me:PivotArrowRight"/>-->
        </Actions>
      </Rule>
      <Condition Source="[Input.KeyFocus]" SourceValue="true">
        <Actions>
          <Set Target="[Model.ChosenIndex]" Value="[Index.Value]"/>
        </Actions>
      </Condition>
      <Condition Source="[Model.ChosenIndex]" SourceValue="[Index.Value]">
        <Actions>
          <!--<Set Target="[ArrowLeft.Content]" Value="image://me:PivotArrowLeftNoFocus"/>
          <Set Target="[ArrowRight.Content]" Value="image://me:PivotArrowRightNoFocus"/>-->
          <!--<Set Target="[ArrowLeft.Visible]" Value="true" />
          <Set Target="[ArrowRight.Visible]" Value="true" />-->
          <Set Target="[Name.Font]" Value="[FocusFont]" />
          <Set Target="[Name.Color]" Value="[FocusColor]"/>
          <Set Target="[PivotPanel.Scale]" Value="1.1,1.1,1.1" />
          <!--<Set Target="[PivotPanel.Alpha]" Value="1" />-->
          <!-- if it's the first time in and we don't have key focus but we're selected go ahead and give us key focus -->
          <Invoke Target="[PivotPanel.NavigateInto]" />
        </Actions>
      </Condition>
      <Condition Source="[Model.ChosenIndex]" ConditionOp="NotEquals" SourceValue="[Index.Value]">
        <Actions>
          <!--<Set Target="[ArrowLeft.Visible]" Value="false" />
          <Set Target="[ArrowRight.Visible]" Value="false" />-->
          <Set Target="[PivotPanel.Scale]" Value="1,1,1" />
          <Set Target="[Name.Font]" Value="[Font]" />
          <Set Target="[Name.Color]" Value="[Color]"/>
          <!--<Set Target="[PivotPanel.Alpha]" Value="0.75" />-->
        </Actions>
      </Condition>
    </Rules>
    <Content>
      <Panel Layout="HorizontalFlow" Name="PivotPanel" CenterPointPercent="0.5,0.5,0.5" FocusOrder="[Index.Value]">
        <Animations>
          <Animation Animation="animation://anim:RegularFastScale" />
          <Animation Animation="animation://anim:RegularFastFade" />
        </Animations>
        <Children>
          <!--<Graphic Name="ArrowLeft" Content="image://me:PivotArrowLeftNoFocus" Margins="0,10,6,0" Scale=".75,.75,.75"/>-->
          <Text Name="Name"  Font="[Font]" Color="[Color]" Content="[Label]" />
          <!--<Graphic Name="ArrowRight" Content="image://me:PivotArrowRightNoFocus" Margins="6,10,0,0" Scale=".75,.75,.75"/>-->
        </Children>
      </Panel>
    </Content>
  </UI>
  <Image Name="PivotArrowLeft"          Source="res://ehres!PIVOT.ARROW.LE.FT.PNG"/>
  <Image Name="PivotArrowLeftNoFocus"   Source="res://ehres!PIVOT.ARROW.LE.FT.NOFOCUS.PNG"/>
  <Image Name="PivotArrowRight"         Source="res://ehres!PIVOT.ARROW.R.IGHT.PNG"/>
  <Image Name="PivotArrowRightNoFocus"  Source="res://ehres!PIVOT.ARROW.RI.GHT.NOFOCUS.PNG"/>
</Mcml>

brianlich

Posts: 34
Joined: Wed Jun 08, 2011 1:49 am
Location:

HTPC Specs: Show details

#3

Post by brianlich » Thu Dec 05, 2013 6:00 pm

Thanks! I'll give it a shot tonight.

MrNorth

Posts: 60
Joined: Sat May 18, 2013 9:46 am
Location:

HTPC Specs: Show details

#4

Post by MrNorth » Wed Jan 29, 2014 2:38 pm

brianlich wrote:Thanks! I'll give it a shot tonight.
Did you solve this? I am getting the same problem. I have made an app that looks identical to say the video gallery in WMC, and when I select a pivot in the pivotmenu, and then press down to browse the gallery, and then press up again, depending on where I am located in the horizontal scroller, I end up at a different pivot. This is very annoying. I use the same pivotsample as you do. The selected pivot is databound to a Choice.

/H

brianlich

Posts: 34
Joined: Wed Jun 08, 2011 1:49 am
Location:

HTPC Specs: Show details

#5

Post by brianlich » Wed Jan 29, 2014 6:21 pm

MrNorth wrote:
brianlich wrote:Thanks! I'll give it a shot tonight.
Did you solve this? I am getting the same problem. I have made an app that looks identical to say the video gallery in WMC, and when I select a pivot in the pivotmenu, and then press down to browse the gallery, and then press up again, depending on where I am located in the horizontal scroller, I end up at a different pivot. This is very annoying. I use the same pivotsample as you do. The selected pivot is databound to a Choice.

/H
I ended up using the samples form sccrgoalie1 and the problem went away.

Post Reply