开发者

Pressing applicationbar button to cycle through panorama items, windows phone 7

My windows phone 7 skills are, at best, terrible. I need help designing a function that will slide to the next or previous panorama item in a panorama control, by merely touching the appropriate applicationbar button.

Consider the following:

<Grid x:Name="Whole" Grid.Row="1">
        <controls:Panorama Name="Chunks" Height="auto" Width="auto">

            <!--Panorama item one-->
            <controls:PanoramaItem x:name="first">
                    <Rectangle Height="auto" Width="auto">
                        <Rectangle.Fill&g开发者_StackOverflow社区t;
                            <ImageBrush x:Name="Logic1"/>
                        </Rectangle.Fill>
                    </Rectangle>
            </controls:PanoramaItem>


            <!--Panorama item two-->
            <controls:PanoramaItem x:name="second">
                <Rectangle Height="auto" Width="auto">
                        <Rectangle.Fill>
                        <ImageBrush x:Name="Logic2"/>
                    </Rectangle.Fill>
                </Rectangle>
            </controls:PanoramaItem>


            <!--Panorama item two-->
            <controls:PanoramaItem x:name="third">
                <Rectangle Height="auto" Width="auto">
                        <Rectangle.Fill>
                        <ImageBrush x:Name="Logic3"/>
                    </Rectangle.Fill>
                </Rectangle>
            </controls:PanoramaItem>

        </controls:Panorama>     
    </Grid>

How would I be able to write the code-behind to select the current panorama item in view, and to slide it left or right with the touch of the applicationbar button? Would the motion be kept? Is this even possible?


You don't!

Technically you could do some major rework of the panorama control or create your own to allow this. But don't.

The panorma creates a method of interacting with the app which is unique to the platform. Users familiar with the phone (i.e. they've used one for a bit. This will be all your users!) will expect that if you create something that looks like a panorama (whether they know what it's called or not) it should behave like every other panorama they're interacted with.

If you start creating non-standard behaviours and interaction methods you risk confusing users as to how to use your app. This is never a good idea if you want them to use it again.

The design documents also explicitly advise against using an application bar with a panorama. There are some technical issues if you do, but this is also a design issue here. The intent with the panorma is that all content is manipulated directly. Application bar buttons are also intended for interaction with the displayed content and this content will vary by panorama item.

If you were forced in to doing this (at gun point!) you may be able to hack it by reloading the same page and programmatically setting the default index to the desired item. This would be VERY hacky though and would have consequences for the background image, etc. Be sure to use the nonlinear navigation service recipe if you go down this route so you don't completely break the back button.


The only way you can programmatically manipulate the displayed page of a panorama control is to add and remove from the collection of items. This causes no end of complications and is in any case not a supported operation.

You can set the SelectedItem of a Pivot control like this.

However, as several people have already commented, the style guide specifically and unambiguously tells you not to use the application bar in Panoramic or Pivot applications.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜