必威体育Betway必威体育官网
当前位置:首页 > IT技术

UWP入门(七)--SplitView详解与页面跳转

时间:2019-08-27 10:40:00来源:IT技术作者:seo实验室小编阅读:81次「手机版」
 

split view

原文:UWP入门(七)--SplitView详解与页面跳转

官方文档,逼着自己用英文看,UWP开发离不开官方文档

1. SplitView 拆分视图控件

拆分视图控件具有一个可展开/可折叠的窗格和一个内容区域

<SplitView>
  <SplitView.content>
    singleObject
  </SplitView.Content>
  <SplitView.Pane>
    singleObject
  </SplitView.Pane>
</SplitView>

A split view’s content area is always visible. The pane can expand and collapse or remain in an open state, and can present itself from either the left side or right side of an APP window. The pane has four modes:

  • overlay

    The pane is hidden until opened. When open, the pane overlays the content area.

    pane不打开是隐藏,打开的时候pane覆盖掉content

  • inline

    The pane is always visible and doesn’t overlay the content area. The pane and content areas pide the available screen real estate.

    pane不打开是隐藏,打开的时候pane推开content

  • CompactOverlay

    A narrow portion of the pane is always visible in this mode, which is just wide enough to show icons. The default closed pane width is 48px, which can be modified with CompactPaneLength. If the pane is opened, it will overlay the content area.

    不打开时,pane留下一点宽度,默认48px,可以用CompactPaneLength修改

  • CompactInline

    A narrow portion of the pane is always visible in this mode, which is just wide enough to show icons. The default closed pane width is 48px, which can be modified with CompactPaneLength. If the pane is opened, it will reduce the space available for content, pushing the content out of its way.

    不打开时,pane留下一点宽度,默认48px,可以用CompactPaneLength修改

2. 页面跳转和SplitView,用static传递了数据

方便你找代码,直接目录跳转

2.1 MainPage

  <StackPanel>
        <StackPanel Orientation="Horizontal">
            <Button Name="HomeButton" Content="Home" Click="HomeButton_Click" Margin="0,0,20,0" />
            <Button Name="BackButton" Content="Back" Click="BackButton_Click" Margin="0,0,20,0" />
            <Button Name="ForwardButton" Content="Forward" Click="ForwardButton_Click" Margin="0,0,20,0" />
            <Button Name="NavigateButton" Content="Navigate Root Frame" Click="NavigateButton_Click" />
        </StackPanel>
        <Frame Name="MyFrame">

        </Frame>
    </StackPanel>
 public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.Initializecomponent();
            //自己有Frme,布局里面的
            MyFrame.Navigate(typeof(Page1));
        }

        private void HomeButton_Click(object sender, RoutedEventArgs e)
        {
            MyFrame.Navigate(typeof(Page1));
        }

        private void BackButton_Click(object sender, RoutedEventArgs e)
        {
            //haha,不用自己写堆栈
            if (MyFrame.CanGoBack)
            {
                MyFrame.GoBack();
            }
        }

        private void ForwardButton_Click(object sender, RoutedEventArgs e)
        {
            if (MyFrame.CanGoForward)
            {
                MyFrame.GoForward();
            }
        }

        private void NavigateButton_Click(object sender, RoutedEventArgs e)
        {
        //注意,这会替换整个页面的Frame
            this.Frame.Navigate(typeof(Page2));
        }
    }

2.2 App.xml.cs

//只可以在应用内访问
 internal static string SomeimportantValue;

2.3 Page1

<StackPanel>
        <TextBlock FontSize="48" Text="Page 1" />
        <HyperlinkButton Content="Go to Page 2"  Click="HyperlinkButton_Click" />
        <HyperlinkButton Content="Go to Microsoft.com" NavigateUri="http://www.microsoft.com"  />
    </StackPanel>
 private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
        {
            Frame.Navigate(typeof(Page2));
        }

2.4 Page2

  private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
        {
            App.SomeImportantValue = ValueTextBox.Text;
            Frame.Navigate(typeof(Page3), ValueTextBox.Text);
            // Frame.Navigate(typeof(Page3), "DEVIL");
        }


        protected override void OnNavigatedTo(navigationEventArgs e)
        {
            if (!String.IsNullOrempty(App.SomeImportantValue))
            {
                ValueTextBox.Text = App.SomeImportantValue;
            }
        }
  <StackPanel>
        <TextBlock FontSize="48" Text="Page 2" />
        <TextBox Name="ValueTextBox" Width="200" />
        <HyperlinkButton Content="Go to Page 3"  Click="HyperlinkButton_Click" />
    </StackPanel>

2.5 Page3

 <StackPanel>
        <TextBlock FontSize="48" Text="Page 3" />
        <TextBox Name="ValueTextBox" Width="200" />
    </StackPanel>
 //页面刚打开的时候调用
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var value = (string)e.parameter;
            ValueTextBox.Text = value;
        }

相关阅读

response.sendRedirect页面跳转无效,原因是在于ajax请

项目想要在后台进行页面跳转,用了response.sendRedirect,但是没反应,debug了一下,发现执行到重定向的时候没反应,当时就是一脸懵逼的,怎

分享到:

栏目导航

推荐阅读

热门阅读