Scaffold ScrollViewRenderer

This commit is contained in:
Frank A. Krueger 2018-04-15 19:29:58 -07:00
parent f309cb9247
commit 95b76f3783
No known key found for this signature in database
GPG Key ID: 0471C67474FFE664
3 changed files with 48 additions and 13 deletions

View File

@ -19,6 +19,7 @@ using Xamarin.Forms;
[assembly: ExportRenderer (typeof (Picker), typeof (PickerRenderer))] [assembly: ExportRenderer (typeof (Picker), typeof (PickerRenderer))]
[assembly: ExportRenderer (typeof (ListView), typeof (ListViewRenderer))] [assembly: ExportRenderer (typeof (ListView), typeof (ListViewRenderer))]
[assembly: ExportRenderer (typeof (ProgressBar), typeof (ProgressBarRenderer))] [assembly: ExportRenderer (typeof (ProgressBar), typeof (ProgressBarRenderer))]
[assembly: ExportRenderer (typeof (ScrollView), typeof (ScrollViewRenderer))]
[assembly: ExportRenderer (typeof (SearchBar), typeof (SearchBarRenderer))] [assembly: ExportRenderer (typeof (SearchBar), typeof (SearchBarRenderer))]
[assembly: ExportRenderer (typeof (Slider), typeof (SliderRenderer))] [assembly: ExportRenderer (typeof (Slider), typeof (SliderRenderer))]
[assembly: ExportRenderer (typeof (Switch), typeof (SwitchRenderer))] [assembly: ExportRenderer (typeof (Switch), typeof (SwitchRenderer))]

View File

@ -0,0 +1,22 @@
using System;
using System.ComponentModel;
using Ooui.Forms.Extensions;
using Xamarin.Forms;
namespace Ooui.Forms.Renderers
{
public class ScrollViewRenderer : ViewRenderer<ScrollView, Div>
{
protected override void OnElementChanged (ElementChangedEventArgs<ScrollView> e)
{
base.OnElementChanged (e);
this.Style.Overflow = "scroll";
}
protected override void OnElementPropertyChanged (object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged (sender, e);
}
}
}

View File

@ -23,6 +23,18 @@ namespace Samples
row1.Children.Add (new Label { Text = longText, FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.End }); row1.Children.Add (new Label { Text = longText, FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.End });
rows.Children.Add (row1); rows.Children.Add (row1);
var row0s = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.Azure };
row0s.Children.Add (new Label { Text = shortText, LineBreakMode = LineBreakMode.WordWrap, WidthRequest = 100 });
row0s.Children.Add (new Label { Text = mediumText, LineBreakMode = LineBreakMode.WordWrap, WidthRequest = 100 });
row0s.Children.Add (new Label { Text = longText, LineBreakMode = LineBreakMode.WordWrap, WidthRequest = 100 });
rows.Children.Add (new ScrollView { Content = row0s });
var row1s = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.GhostWhite };
row1s.Children.Add (new Label { Text = shortText, FontAttributes = FontAttributes.Bold, WidthRequest = 100, HorizontalOptions = LayoutOptions.Start });
row1s.Children.Add (new Label { Text = mediumText, FontAttributes = FontAttributes.Bold, WidthRequest = 100, HorizontalOptions = LayoutOptions.FillAndExpand });
row1s.Children.Add (new Label { Text = longText, FontAttributes = FontAttributes.Bold, WidthRequest = 100, HorizontalOptions = LayoutOptions.End });
rows.Children.Add (new ScrollView { Content = row1s });
var row2 = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.Azure }; var row2 = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.Azure };
row2.Children.Add (new Entry { Text = shortText, FontSize = 8, VerticalOptions = LayoutOptions.Center }); row2.Children.Add (new Entry { Text = shortText, FontSize = 8, VerticalOptions = LayoutOptions.Center });
row2.Children.Add (new Entry { Text = shortText, FontSize = 16, VerticalOptions = LayoutOptions.Center }); row2.Children.Add (new Entry { Text = shortText, FontSize = 16, VerticalOptions = LayoutOptions.Center });
@ -49,7 +61,7 @@ namespace Samples
row5.Children.Add (new Button { Text = shortText, FontSize = 32, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold }); row5.Children.Add (new Button { Text = shortText, FontSize = 32, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold });
rows.Children.Add (row5); rows.Children.Add (row5);
var row6 = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.GhostWhite }; var row6 = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.Azure };
row6.Children.Add (new DatePicker { VerticalOptions = LayoutOptions.Center }); row6.Children.Add (new DatePicker { VerticalOptions = LayoutOptions.Center });
row6.Children.Add (new TimePicker { VerticalOptions = LayoutOptions.Center }); row6.Children.Add (new TimePicker { VerticalOptions = LayoutOptions.Center });
rows.Children.Add (row6); rows.Children.Add (row6);