locked
How to move a large page

    Question

  • Hello all, I set the MainPage's width larger than the device's width, then I use two buttons(one named "to left", another named "to right" ) move it to left or right.

    how to move it.

    <Page
        x:Class="BigPage.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:BigPage"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
        Width="600"
        >
    </Page>
    Width = "600"


    • Edited by oneonce Wednesday, March 18, 2015 3:50 PM
    Wednesday, March 18, 2015 3:50 PM

Answers

  • You could place the page's contents within a scrollviewer, which is far better than having buttons to move left and right. Then the user can simply drag with their finger.

     <ScrollViewer HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Disabled">
    <Grid></Grid>
    </ScrollViewer>


    I'm a self-taught noob amateur. Please take this into account when responding to my posts or when taking advice from me.

    • Marked as answer by oneonce Thursday, March 19, 2015 2:25 AM
    Thursday, March 19, 2015 2:17 AM

All replies

  • I use the property of Margin can move the page, is there a better way?

    private void button_movePageToLeft_Click(object sender, RoutedEventArgs e)
    {
        Rect rc = Window.Current.Bounds;
        double width = this.ActualWidth;
        double height = this.ActualHeight;
    
        Thickness tk = this.Margin;
    
        tk.Left -= 10;
        if (Math.Abs(tk.Left) > Math.Abs(rc.Width - width))
        {
            tk.Left = Math.Abs(rc.Width - width) * -1;
        }
        this.Margin = tk;
    }
    
    private void button_movePageToRight_Click(object sender, RoutedEventArgs e)
    {
        Rect rc = Window.Current.Bounds;
        double width = this.ActualWidth;
        double height = this.ActualHeight;
    
        Thickness tk = this.Margin;
    
        tk.Left += 10;
        if (tk.Left > 0)
        {
            tk.Left = 0;
        }
        this.Margin = tk;
    }

    Wednesday, March 18, 2015 4:05 PM
  • You could place the page's contents within a scrollviewer, which is far better than having buttons to move left and right. Then the user can simply drag with their finger.

     <ScrollViewer HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Disabled">
    <Grid></Grid>
    </ScrollViewer>


    I'm a self-taught noob amateur. Please take this into account when responding to my posts or when taking advice from me.

    • Marked as answer by oneonce Thursday, March 19, 2015 2:25 AM
    Thursday, March 19, 2015 2:17 AM