MCML Scroll Button PageUp jumps to first item in list
In BeebMC when you select a channel, you are presented with the list of programs available to "Listen Again". You can scroll up and down the list using a remote control, or by positioning your mouse just before the first item, or just after the last item.
I've had a request from someone that has a touch panel. They have no easy way of scrolling through their list. I've decided to add a couple of arrow buttons to let you page up/down through the list. This was pretty easy. I first added a couple of buttons to my Content:
<con:TouchButton Name="ScrollUpButton" Command="[ScrollUpCommand]" Picture="resx://BeebMC/BeebMC.Resources/arrow_up_blue"> <LayoutInput> <FormLayoutInput Top="Parent, 0.2" Left="Parent,0.05"/> </LayoutInput> </con:TouchButton> <con:TouchButton Name="ScrollDownButton" Command="[ScrollDownCommand]" Picture="resx://BeebMC/BeebMC.Resources/arrow_down_blue"> <LayoutInput> <FormLayoutInput Bottom="Parent, 0.80" Left="Parent,0.05"/> </LayoutInput> </con:TouchButton>
When the user clicks the button, I page up or down the scroller:
<Changed Source="[ScrollUpCommand.Invoked]"> <Actions> <Invoke Target="[ScrollingData.PageUp]"/> </Actions> </Changed> <Changed Source="[ScrollDownCommand.Invoked]"> <Actions> <Invoke Target="[ScrollingData.PageDown]"/> </Actions> </Changed>
I tested and all seemed to work well, however then I noticed that although paging down through the list worked fine, paging up was jumping straight to the first item in the list :-(
Eventually I discovered the problem. When you click the Up button, the scroll area loses focus, and so it seems to lose track of where it was in the list. I'm not sure why it works for the Down button.
In any event, the solution was to add a rule to my TouchButton UI to essentially tell it not to grab focus:
<Default Target="[Input.KeyInteractive]" Value="false" />
Now it works and I am close to releasing version 2.1 of BeebMC, which should work with the Media Center TV Pack too.