简体   繁体   English

在 Silverlight/Wp7 中单击时,如何从容器中弹出控件以使其全屏显示?

[英]How can I pop a control out of it's container to make it full screen when clicked in Silverlight/Wp7?

So I have a Panorama control and the PanoramaItems are programmatically added to the control using the following template.所以我有一个全景控件,PanoramaItems 使用以下模板以编程方式添加到控件中。

<UserControl>
    <Grid x:Name="LayoutRoot">
            <controls:PanoramaItem Name="sitePanoramaItem" Header="{Binding Name}">
            <Controls:DockPanel VerticalAlignment="Stretch">
                <StackPanel Orientation="Horizontal" Margin="0,10,0,0" Controls:DockPanel.Dock="Top">
                    <Image Source="../Images/action.png" Width="64"  />
                    <TextBlock Text="{Binding Stats, Mode=TwoWay}" FontSize="45" Margin="15,0,0,0" />
                </StackPanel>
                <Grid x:Name="graphCanvas" HorizontalAlignment="Stretch" Margin="10,10,10,10">    </Grid>
            </Controls:DockPanel>
        </controls:PanoramaItem>
    </Grid>
</UserControl>

When I click on graphCanvas what I'd like to do is sorta pop the graphCanvas out and display that fullscreen then when I click again restore it to where it was.当我单击graphCanvas时,我想做的是将graphCanvas弹出并全屏显示,然后当我再次单击时将其恢复到原来的位置。 I've been all over this site and Google and can't find anything similar to what I'm looking for.我一直在这个网站和谷歌上,找不到任何与我正在寻找的东西相似的东西。

I would still like to maintain the Panorama control functionality so that the graphCanvas is still the only one visible but you can cycle through them.我仍然想维护全景控件功能,以便graphCanvas仍然是唯一可见的,但您可以循环浏览它们。 Currently I have it sorta working in that I remove the Grid from the DockPanel and put it directly in the LayoutRoot while making the sitePanoramaItem collapsed.目前,我让它有点工作,因为我从DockPanel中删除了 Grid 并将其直接放在LayoutRoot中,同时使sitePanoramaItem折叠。 However, it's not fullscreen as the Panorama name is still visible (I guess I could hide that as well...) When I put the graphCanvas back int he DockPanel the size of the canvas is all screwed up.但是,它不是全屏的,因为全景名称仍然可见(我想我也可以隐藏它......)当我将graphCanvas放回DockPanel时,canvas 的大小全部搞砸了。

I was hoping there was a simpler way.我希望有一个更简单的方法。

Is it even possible?甚至可能吗?

It is possible to create the UI you describe but it's not going to be simple.可以创建您描述的 UI,但这并不简单。 You're on the right track with removing it in code and adding it the LayoutRoot and making the Panorama hidden.您在代码中将其删除并将其添加到 LayoutRoot 并使全景图隐藏,从而走在正确的轨道上。 However you would have to code the scrolling behavior yourself and that is going to be quite tricky - especially making it feel the way to panorama does.但是,您必须自己编写滚动行为代码,这将非常棘手——尤其是让它感觉像全景图一样。

One trick you could try is actually layer a PivotControl on top of your Panorama and have it be collapsed by default.您可以尝试的一个技巧实际上是在您的全景图顶部放置一个 PivotControl,并使其默认折叠。 Also edit it's template to remove all default content eg: remove the header control, set margins to 0, etc).还要编辑它的模板以删除所有默认内容,例如:删除 header 控件,将边距设置为 0 等)。 Then when you want to go full screen you can remove all the graphCanvases from the Panorama items and and add them to new PivotItems in the PivotControl.然后,当您想要 go 全屏时,您可以从全景项目中删除所有 graphCanvases,并将它们添加到 PivotControl 中的新 PivotItems。 Then hide the Panorama and show the Pivot.然后隐藏全景图并显示 Pivot。 This will give you scrolling capability for free and the illusion of full screen.这将为您提供免费的滚动功能和全屏的错觉。

Having said all that I'm not sure I would recommend this.说了这么多,我不确定我会推荐这个。 The more common approach would be to simply be to navigate to another page when the user selects an item and handle the full screen aspects there (possibly using the Pivot control again for scrolling).更常见的方法是在用户选择一个项目时简单地导航到另一个页面并在那里处理全屏方面(可能再次使用 Pivot 控件进行滚动)。 And when you want to leave "fullscreen" mode simply navigate back to the first page.当您想离开“全屏”模式时,只需导航回第一页。 Handling Tombstoning of the fullscreen state will be much easier with this approach for one thing.一方面,使用这种方法处理全屏 state 的墓碑会容易得多。

You can try making the graphCanvas a Page and putting it in a different XAML.您可以尝试将 graphCanvas 设为 Page 并将其放入不同的 XAML 中。 Then add a frame (name it InnerFrame for example) in the same place where you have the graphCanvas right now and navigate to that page with InnerFrame.然后在您现在拥有 graphCanvas 的同一位置添加一个框架(例如,将其命名为 InnerFrame),并使用 InnerFrame 导航到该页面。 When the frame is clicked, you navigate with the RootFrame of the app to your graphCanvas page.单击框架时,您将使用应用程序的 RootFrame 导航到您的 graphCanvas 页面。 When you decide to close it, just navigate back with the RootFrame.当您决定关闭它时,只需使用 RootFrame 导航回来。

Hope it's clear enough:)希望它足够清楚:)

Edit: Navigation in WP7 works very similar as the standard navigation in Silverlight 4, but it's a bit more restrictive.编辑: WP7 中的导航与 Silverlight 4 中的标准导航非常相似,但限制性更强。 Just throw a PhoneApplicationFrame in your XAML like this:只需像这样在 XAML 中扔一个 PhoneApplicationFrame :

<phone:PhoneApplicationFrame x:Name="Frame" />

This is basically the same as a Silverlight frame.这与 Silverlight 车架基本相同。 All the pages you create inherit from PhoneApplicationPage by default, so they can be showed in a frame without any changes.默认情况下,您创建的所有页面都继承自 PhoneApplicationPage,因此它们可以在框架中显示而无需任何更改。

Your whole application actually runs on a PhoneApplicationFrame.您的整个应用程序实际上是在 PhoneApplicationFrame 上运行的。 If you take a look at your App class you will see this:如果您查看您的应用程序 class,您将看到:

public PhoneApplicationFrame RootFrame { get; private set; }

Here's the MSDN documentation for the navigation system on WP7这是 WP7 上导航系统的 MSDN 文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM