Windows 8 Store Apps Learning (9) ScrollViewer Control Basics

Source: Internet
Author: User
Tags visibility xmlns

Introduced

Re-imagine the ScrollViewer of Windows 8 Store Apps

The basic application of demonstrating ScrollViewer

The basic application of demonstrating ScrollBar

The basic application of demonstrating Scrollcontentpresenter

Example

1, the basic application of ScrollViewer

Scrollviewer/demo.xaml

<page x:class= "XamlDemo.Controls.ScrollViewer.Demo" xmlns= "Http://schemas.microsoft.com/winfx/2006/xaml/prese Ntation "xmlns:x=" Http://schemas.microsoft.com/winfx/2006/xaml "xmlns:local=" using: XamlDemo.Controls.ScrollViewer "xmlns:d=" http://schemas.microsoft.com/expression/blend/2008 "xmlns:mc=" http:// schemas.openxmlformats.org/markup-compatibility/2006 "mc:ignorable=" D "> <grid background=" Transparent "&
        Gt <stackpanel margin= "0 0 0" > <textblock name= "lblmsg"/> < !--ScrollViewer-Scrolling View Control Content-scrolling view contents Isdeferredscrollingen abled-Enable deferred scrolling, when too much scrolling is enabled, enabling delay mixing can improve performance, the default value is False Horizontalscrollmode-the behavior of the horizontal scroll bar, Windows.UI.Xaml.Co Ntrols. Scrollmode enumeration (Disabled, Enabled, Auto) Verticalscrollmode-the behavior of the vertical scroll bar HORIZONTALSC Rollbarvisibility-the visibility of the horizontal scroll bar, Windows.ui.Xaml.Controls.ScrollBarVisibility enumeration (Disabled, Auto, Hidden, Visible) verticalscrollbarvisibility-Vertical roll Visibility viewchanged-Events triggered when scrolling occurs--> <scrollviewer name= "ScrollViewer" W Idth= "height=" margin= "0 0 0" horizontalalignment= "left" isdeferredscrollingenabled= "False" viewchanged= "Scrollviewer_viewchanged_1" horizontalscrollmode= "Enabled" verticalscrollmode= "Enabled" horizontalscrollbarvisibility= "Visible" Verticalscrollbar visibility= "Visible" > <ScrollViewer.Content> <image source= "/ASSETS/LOGO.P
                
            Ng "width=" 1000 "/> </ScrollViewer.Content> </ScrollViewer> <stackpanel orientation= "Horizontal" > <!--Scrolls the contents of ScrollViewer to the center of ScrollViewer
                T <bUtton content= "center" click= "Button_click_1"/> </StackPanel> </stackpanel&gt
    ; </Grid> </Page>

Scrollviewer/demo.xaml.cs

* * ScrollViewer-scrolling View Control * This example is used to demonstrate the basic usage of ScrollViewer * * using Windows.UI.Xaml;
    
Using Windows.UI.Xaml.Controls;
        Namespace XamlDemo.Controls.ScrollViewer {public sealed partial class Demo:page {public Demo () {this.
        InitializeComponent ();
            } private void Scrollviewer_viewchanged_1 (object sender, Scrollviewerviewchangedeventargs e) {
    
            Lblmsg.text = ""; * * ScrollViewer-scrolling View Control * computedhorizontalscrollbarvisibility-the visibility of the current horizontal scroll bar, such as when Horizon When Talscrollbarvisibility is set to Auton, the computedhorizontalscrollbarvisibility can be used to determine whether the current horizontal scroll bar is visible * computed Verticalscrollbarvisibility-The visibility of the current vertical scroll bar extentwidth-scrollviewer The content within the width of * extenthe
             High * viewportwidth of content within the ight-scrollviewer-wide * viewportheight of the visual area-high in the visual area
     * HorizontalOffset-Horizontal offset of scrolling content        * Verticaloffset-The vertical offset of the scrolling content * Scrollablewidth-the size of the horizontal direction of the scrollable region * Scrolla     Bleheight-The vertical size of the scrollable area * * Scrolltohorizontaloffset ()-scrolls to the specified horizontal offset * Scrolltoverticaloffset ()-scroll to the specified vertical offset/lblmsg.text = "Computedhorizontalscrollbarvi
            Sibility: "+ scrollviewer.computedhorizontalscrollbarvisibility;
            Lblmsg.text + = "\ r \ n";
            Lblmsg.text + = "computedverticalscrollbarvisibility:" + scrollviewer.computedverticalscrollbarvisibility;
            Lblmsg.text + = "\ r \ n";
            Lblmsg.text + = "Extentwidth:" + scrollviewer.extentwidth;
            Lblmsg.text + = "\ r \ n";
            Lblmsg.text + = "Extentheight:" + scrollviewer.extentheight;
            Lblmsg.text + = "\ r \ n";
            Lblmsg.text + = "Viewportwidth:" + scrollviewer.viewportwidth;
            Lblmsg.text + = "\ r \ n"; Lblmsg.text + = "Viewportheight:" + scrollvIewer.
            Viewportheight;
            Lblmsg.text + = "\ r \ n";
            Lblmsg.text + = "HorizontalOffset:" + scrollviewer.horizontaloffset;
            Lblmsg.text + = "\ r \ n";
            Lblmsg.text + = "Verticaloffset:" + scrollviewer.verticaloffset;
            Lblmsg.text + = "\ r \ n";
            Lblmsg.text + = "Scrollablewidth:" + scrollviewer.scrollablewidth;
            Lblmsg.text + = "\ r \ n";
            Lblmsg.text + = "Scrollableheight:" + scrollviewer.scrollableheight;
        Lblmsg.text + = "\ r \ n"; } private void Button_click_1 (object sender, RoutedEventArgs e) {Scrollviewer.scrolltoho
            Rizontaloffset (SCROLLVIEWER.SCROLLABLEWIDTH/2);
        Scrollviewer.scrolltoverticaloffset (SCROLLVIEWER.SCROLLABLEHEIGHT/2); }
    }
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.