当前位置: 首页>>代码示例>>C#>>正文


C# ScrollView.ScrollToAsync方法代码示例

本文整理汇总了C#中Xamarin.Forms.ScrollView.ScrollToAsync方法的典型用法代码示例。如果您正苦于以下问题:C# ScrollView.ScrollToAsync方法的具体用法?C# ScrollView.ScrollToAsync怎么用?C# ScrollView.ScrollToAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Xamarin.Forms.ScrollView的用法示例。


在下文中一共展示了ScrollView.ScrollToAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ScrollingDemoCode

		public ScrollingDemoCode ()
		{
			Title = "ScrollView Demo - C#";
			var scroll = new ScrollView ();
			var label = new Label { Text = "Position" };
			var target = new Entry ();
			var stack = new StackLayout ();
			scroll.Content = stack;
			stack.Children.Add (label);
			stack.Children.Add (new BoxView { BackgroundColor = Color.Red, HeightRequest = 600, WidthRequest = 150 });
			stack.Children.Add (target);
			Content = scroll;
			scroll.ScrollToAsync (target, ScrollToPosition.Center, true);
			scroll.Scrolled+= (object sender, ScrolledEventArgs e) => {
				label.Text = "Position: " + e.ScrollX + " x " + e.ScrollY;
			};
		}
开发者ID:RickySan65,项目名称:xamarin-forms-samples,代码行数:17,代码来源:ScrollingDemoCode.cs

示例2: CommunityMediaViewer

		public CommunityMediaViewer ( List<PurposeColor.Constants.MediaDetails> mediaList )
		{
			NavigationPage.SetHasNavigationBar (this, false);
			masterLayout = new CustomLayout ();
			masterLayout.BackgroundColor = Color.Black;// Color.FromRgb(244, 244, 244);
			masterScroll = new ScrollView ();
			masterScroll.BackgroundColor = Color.Black;//Color.FromRgb(244, 244, 244);
			progressBar = DependencyService.Get<IProgressBar> ();

			mainTitleBar = new PurposeColorTitleBar (Color.FromRgb (8, 135, 224), "Purpose Color", Color.Black, "back", true);
			subTitleBar = new PurposeColorSubTitleBar (Constants.SUB_TITLE_BG_COLOR, "Gem Media Viewer", false);
			subTitleBar.BackButtonTapRecognizer.Tapped += async (object sender, EventArgs e) => {
				try {
					await Navigation.PopAsync ();
				} catch (Exception) {
				}
			};

			mainTitleBar.imageAreaTapGestureRecognizer.Tapped += (object sender, EventArgs e) => 
			{
				App.masterPage.IsPresented = !App.masterPage.IsPresented;
			};
				

			masterStack = new CustomLayout ();
			masterStack.BackgroundColor = Color.Transparent;
			masterStack.HorizontalOptions = LayoutOptions.Center;

			StackLayout bottomAndLowerControllStack = new StackLayout {
				Orientation = StackOrientation.Vertical,
				BackgroundColor = Color.Transparent,
				Spacing = 1,
				Padding = new Thickness (0, 5, 0, 5),
				WidthRequest = App.screenWidth,
			};


			ScrollView imgScrollView = new ScrollView ();
			imgScrollView.Orientation = ScrollOrientation.Horizontal;

			StackLayout horizmgConatiner = new StackLayout ();
			horizmgConatiner.Orientation = StackOrientation.Horizontal;


			CustomImageButton nextImg = new CustomImageButton ();
			nextImg.ImageName = "next.png";
			nextImg.WidthRequest = 40;
			nextImg.HeightRequest = 65;
				
			nextImg.Clicked += async (object sender, EventArgs e) => 
			{

				double curX = imgScrollView.ScrollX;
				double imgWidth = App.screenWidth * 100 / 100;

				if( Device.OS == TargetPlatform.iOS )
				{
					if( curX + imgWidth + 15 < imgScrollView.ContentSize.Width )
						await imgScrollView.ScrollToAsync( curX + imgWidth , 0, true );
				}
				else
				{
					await imgScrollView.ScrollToAsync( curX + imgWidth , 0, true );
				}
					
			};


			CustomImageButton prevImg = new CustomImageButton ();
			prevImg.ImageName = "prev.png";
			prevImg.WidthRequest = 40;
			prevImg.HeightRequest = 65;
			prevImg.Clicked += async (object sender, EventArgs e) => 
			{
				double curX = imgScrollView.ScrollX;
				double imgWidth = App.screenWidth * 90 / 100;
				if( curX > 0 )
				await imgScrollView.ScrollToAsync( curX - App.screenWidth , 0, true );
			};


			#region MEDIA LIST

			if (mediaList != null) 
			{
				foreach (var item in mediaList) 
				{
					TapGestureRecognizer videoTap = new TapGestureRecognizer ();
					videoTap.Tapped += OnActionVideoTapped;

					Image img = new Image ();
					bool isValidUrl = ( item.Url != null && !string.IsNullOrEmpty ( item.Url )) ? true : false;
					string source = (isValidUrl) ? item.Url : Device.OnPlatform ("noimage.png", "noimage.png", "//Assets//noimage.png");
					string fileExtenstion = Path.GetExtension (source);
					bool isImage = (fileExtenstion == ".png" || fileExtenstion == ".jpg" || fileExtenstion == ".jpeg") ? true : false;
					img.WidthRequest = App.screenWidth;
					img.HeightRequest = App.screenWidth;
					img.Aspect = Aspect.AspectFill;
					img.ClassId = null;
					if (item != null && item.MediaType == "mp4") 
//.........这里部分代码省略.........
开发者ID:praveenmohanmm,项目名称:PurposeColor_Bkp_Code,代码行数:101,代码来源:CommunityMediaViewer.cs

示例3: QuestionsScreen


//.........这里部分代码省略.........
                    new ColumnDefinition {Width = App.screenWidth / 5 - 32},
                    new ColumnDefinition {Width = App.screenWidth / 5},
                    new ColumnDefinition {Width = App.screenWidth / 5},
                    new ColumnDefinition {Width = App.screenWidth / 5},
                    new ColumnDefinition {Width = App.screenWidth / 10},
                    new ColumnDefinition {Width = 0}
                }
            };

            Label backLbl = new Label
            {
                Text = "<",
                BackgroundColor = Color.Black,
                TextColor = Color.White,
                FontSize = 24,
                XAlign = TextAlignment.Center,
                YAlign = TextAlignment.Center
            };

            backLbl.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() => goBack())
            }); 

            Label nextLbl = new Label
            {
                Text = ">",
                BackgroundColor = Color.Black,
                TextColor = Color.White,
                FontSize = 24,
                XAlign = TextAlignment.Center,
                YAlign = TextAlignment.Center
            };

            nextLbl.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() => goToNextActivity()),
            }); 


            //adding each element to the grid
            pageGrid.Children.Add(backLbl, 1, 1); //back button

            pageGrid.Children.Add(logoLayout, 2, 7, 1, 2); //qut logo

            pageGrid.Children.Add(questionContent, 1, 7, 2, 3); //scrolling editor text

            pageGrid.Children.Add(questionIconLayout, 1, 3, 3, 4); //questions button

            pageGrid.Children.Add(triviaIconLayout, 3, 3); //trivia button

            pageGrid.Children.Add(taskIconLayout, 4, 3); //tasks button

            pageGrid.Children.Add(cameraIconLayout, 5, 3); //camera button

            pageGrid.Children.Add(nextLbl, 6, 3); //next activity button

            //creating a stacklayout and adding the grid to it
            StackLayout innerContent = new StackLayout
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.Center,
            };

            innerContent.Children.Add(pageGrid);

            //making the pages content the stacklayout with the grid
            this.Content = innerContent;

            //add padding to account for the iOS status bar
            this.Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0);
            this.BackgroundImage = "background.png";

            //when the editor with the questions is unfocused
            //invalidate it so that it reformats the height
            questions.TextChanged += (s, e) =>
            {
                reformatEditorHeight(questions);
            };

            //on iOS when you click the text in the editor, it doesn't
            //automatically scroll the editor down to where the text is
            //with this added functionality when the question editor is
            //focused it should scroll to the position the user clicked
            //and when unfocused scroll back to the beginning of the
            //editor element.
            if (Device.OS == TargetPlatform.iOS)
            {
                questions.Focused += (s, e) =>
                {
                    double scrollPosition = questions.Y;
                    questionText.ScrollToAsync(0, scrollPosition, false);
                };

                questions.Unfocused += (s, e) =>
                {
                    questionText.ScrollToAsync(0, 0, false);
                };
            }
        }
开发者ID:EclipseSystems,项目名称:INB302-IT-Capstone-Unit,代码行数:101,代码来源:QuestionsScreen.cs


注:本文中的Xamarin.Forms.ScrollView.ScrollToAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。