本文整理匯總了C#中Xamarin.Forms.StackLayout.SetValue方法的典型用法代碼示例。如果您正苦於以下問題:C# StackLayout.SetValue方法的具體用法?C# StackLayout.SetValue怎麽用?C# StackLayout.SetValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Xamarin.Forms.StackLayout
的用法示例。
在下文中一共展示了StackLayout.SetValue方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: SetupContentView
private View SetupContentView()
{
Grid grid = new Grid {
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
RowDefinitions = {
new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }
},
};
// Background.jpg: Macro Background Print 9 by Jason Weymouth Photography (https://www.flickr.com/photos/jason_weymouth/)
// License: Attribution-ShareAlike 2.0 Generic (https://creativecommons.org/licenses/by-sa/2.0/)
// Additional license information can be found in Background.jpg.license in root of repository.
Image backgroundImage = new Image { Source = "Background.jpg", HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, Aspect = Aspect.AspectFill, Opacity = 1 };
backgroundImage.SetValue(Grid.RowSpanProperty, 1);
backgroundImage.SetValue(Grid.ColumnSpanProperty, 1);
grid.Children.Add(backgroundImage);
StackLayout mask = new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Black, Opacity = 0.1 };
mask.SetValue(Grid.RowSpanProperty, 1);
mask.SetValue(Grid.ColumnSpanProperty, 1);
grid.Children.Add(mask);
ScrollView scrollView = new ScrollView
{
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
Orientation = ScrollOrientation.Vertical
};
StackLayout loginLayout = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
Spacing = 10
};
Label loginLabel = new Label { Text = "Login to Xamarin Office 365 Demo", TextColor = Color.White, FontSize = 24 };
loginLayout.Children.Add(new StackLayout { Children = { loginLabel }, Padding = new Thickness(0,0,0,30) });
Button loginButton = new Button { Text = "Log In", FontSize = 18, TextColor = Color.White, BackgroundColor = Color.FromRgb(45, 180, 40), BorderColor = Color.White, BorderRadius = 5, BorderWidth = 1 };
loginButton.Clicked += LoginButton_Clicked;
loginLayout.Children.Add(loginButton);
scrollView.Content = loginLayout;
grid.Children.Add(scrollView);
Label backgroundAttributionLabel = new Label { Text = "Macro Background Print 9 by Jason Weymouth Photography", TextColor = Color.White, FontSize = 12 };
grid.Children.Add(new StackLayout { Children = { backgroundAttributionLabel }, HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.End, Padding = new Thickness(10,0,0,6) });
return grid;
}
示例2: SetupBackgroundGrid
private void SetupBackgroundGrid()
{
_backgroundGrid = new Grid {
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
RowDefinitions = {
new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }
}
};
// Background.jpg: Macro Background Print 9 by Jason Weymouth Photography (https://www.flickr.com/photos/jason_weymouth/)
// License: Attribution-ShareAlike 2.0 Generic (https://creativecommons.org/licenses/by-sa/2.0/)
// Additional license information can be found in Background.jpg.license in root of repository.
Image backgroundImage = new Image { Source = "Background.jpg", HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, Aspect = Aspect.AspectFill, Opacity = 1 };
backgroundImage.SetValue(Grid.RowSpanProperty, 1);
backgroundImage.SetValue(Grid.ColumnSpanProperty, 1);
_backgroundGrid.Children.Add(backgroundImage);
StackLayout mask = new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Black, Opacity = 0.1 };
mask.SetValue(Grid.RowSpanProperty, 1);
mask.SetValue(Grid.ColumnSpanProperty, 1);
_backgroundGrid.Children.Add(mask);
}