本文整理汇总了C#中Windows.UI.Xaml.Controls.StackPanel.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# StackPanel.SetValue方法的具体用法?C# StackPanel.SetValue怎么用?C# StackPanel.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.UI.Xaml.Controls.StackPanel
的用法示例。
在下文中一共展示了StackPanel.SetValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: populateRecipes
private void populateRecipes()
{
// PivotItem pvt;
int i = 0;
if(recipeFinalList.Count == 0)
{
PivotItem pivotItem = new PivotItem();
pivotItem.Header = "No Results";
TextBlock txtTitle = new TextBlock();
txtTitle.Text = "No Results Found";
txtTitle.Margin = new Thickness(10, 10, 10, 10);
pivotItem.Content = txtTitle;
pvtRecipes.Items.Add(pivotItem);
}
foreach(Model.Recipef2f recipe in recipeFinalList)
{
PivotItem pivotItem = new PivotItem();
pivotItem.Header = recipe.Title;
Grid grid = new Grid();
grid.ColumnDefinitions.Add(new ColumnDefinition());
grid.ColumnDefinitions.Add(new ColumnDefinition());
Image img = new Image();
img.Source = new BitmapImage(new Uri(recipe.ImageUrl));
img.SetValue(Grid.ColumnProperty, 0);
grid.Children.Add(img);
Image favorite = new Image();
favorite.Name = "favoriteSymbol" + i.ToString();
BitmapImage starImage = new BitmapImage();
starImage.UriSource = new Uri("https://image.freepik.com/free-icon/favorites-star-outlined-symbol_318-69168.png");
favorite.Source = starImage;
favorite.HorizontalAlignment = HorizontalAlignment.Right;
favorite.VerticalAlignment = VerticalAlignment.Top;
favorite.Width = 15;
favorite.Height = 15;
favorite.Tapped += Favorite_Tapped; ;
favorite.SetValue(Grid.ColumnProperty, 1);
i++;
StackPanel stk = new StackPanel();
stk.SetValue(Grid.ColumnProperty, 1);
stk.Name = "recipeStk";
stk.Children.Add(favorite);
TextBlock txtTitle= new TextBlock();
txtTitle.Text = "Title: " + recipe.Title;
txtTitle.Margin = new Thickness(10, 10, 10, 10);
txtTitle.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtTitle);
TextBlock txtRecipeId = new TextBlock();
txtRecipeId.Text = "RecipeId: " + recipe.RecipeId;
txtRecipeId.Margin = new Thickness(10,10,10,10);
txtRecipeId.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtRecipeId);
TextBlock txtIngredientsList = new TextBlock();
txtIngredientsList.Text = "Ingredients: " + recipe.IngredientsList;
txtIngredientsList.Margin = new Thickness(10, 10, 10, 10);
txtIngredientsList.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtIngredientsList);
TextBlock txtSocialRank = new TextBlock();
txtSocialRank.Text = "Social Rank: " + recipe.SocialRank.ToString();
txtSocialRank.Margin = new Thickness(10, 10, 10, 10);
txtSocialRank.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtSocialRank);
TextBlock txtPublisher = new TextBlock();
txtPublisher.Text = "Publisher: " + recipe.Publisher;
txtPublisher.Margin = new Thickness(10, 10, 10, 10);
txtPublisher.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtPublisher);
TextBlock txtPublisherUrl = new TextBlock();
txtPublisherUrl.Text = "Publisher URL: " + recipe.PublisherUrl;
txtPublisherUrl.Margin = new Thickness(10, 10, 10, 10);
txtPublisherUrl.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtPublisherUrl);
TextBlock txtSourceUrl = new TextBlock();
txtSourceUrl.Text = "Source URL: " + recipe.SourceUrl;
txtSourceUrl.Margin = new Thickness(10, 10, 10, 10);
txtSourceUrl.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtSourceUrl);
TextBlock txtF2fUrl = new TextBlock();
txtF2fUrl.Text = "F2F URL: " + recipe.F2fUrl;
txtF2fUrl.Margin = new Thickness(10, 10, 10, 10);
txtF2fUrl.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtF2fUrl);
grid.Children.Add(stk);
pivotItem.Content = grid;
pvtRecipes.Items.Add(pivotItem);
//.........这里部分代码省略.........
示例2: populateRecipes
private void populateRecipes()
{
// PivotItem pvt;
if(listRecipes.Count == 0 && listf2fRecipe.Count == 0)
{
PivotItem pivotItem = new PivotItem();
pivotItem.Header ="Favorites";
TextBlock txtTitle = new TextBlock();
txtTitle.Text = "No Favorites at this Point";
txtTitle.Margin = new Thickness(10, 10, 10, 10);
txtTitle.SetValue(Grid.ColumnProperty, 1);
pivotItem.Content = txtTitle;
pvtFavorites.Items.Add(pivotItem);
}
int yummly = 0;
int i = 0;
foreach (Model.ResponseYummly recipe in listRecipes)
{
PivotItem pivotItem = new PivotItem();
pivotItem.Name = "yummly" + yummly.ToString();
yummly++;
pivotItem.Header = recipe.RecipeName;
Grid grid = new Grid();
grid.ColumnDefinitions.Add(new ColumnDefinition());
grid.ColumnDefinitions.Add(new ColumnDefinition());
Image img = new Image();
img.Source = new BitmapImage(new Uri(recipe.ImageUrl));
img.SetValue(Grid.ColumnProperty, 0);
grid.Children.Add(img);
Image favorite = new Image();
favorite.Name = "favoriteSymbol" + i.ToString();
i++;
BitmapImage starImage = new BitmapImage();
starImage.UriSource = new Uri("http://images.all-free-download.com/images/graphiclarge/favorite_icon_55521.jpg");
favorite.Source = starImage;
favorite.HorizontalAlignment = HorizontalAlignment.Right;
favorite.VerticalAlignment = VerticalAlignment.Top;
favorite.Width = 15;
favorite.Height = 15;
favorite.Tapped += Favorite_Tapped;
favorite.SetValue(Grid.ColumnProperty, 1);
StackPanel stk = new StackPanel();
stk.Name = "recipeStk";
stk.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(favorite);
TextBlock txtTitle = new TextBlock();
txtTitle.Text = "Title: " + recipe.RecipeName;
txtTitle.Margin = new Thickness(10, 10, 10, 10);
txtTitle.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtTitle);
TextBlock txtRecipeId = new TextBlock();
txtRecipeId.Text = "RecipeId: " + recipe.Id;
txtRecipeId.Margin = new Thickness(10, 10, 10, 10);
txtRecipeId.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtRecipeId);
TextBlock txtIngredientsList = new TextBlock();
txtIngredientsList.Text = "Ingredients: " + recipe.Ingredients.Replace("\",", "\n");
txtIngredientsList.Margin = new Thickness(10, 10, 10, 10);
txtIngredientsList.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtIngredientsList);
TextBlock txtSocialRank = new TextBlock();
txtSocialRank.Text = "Social Rank: " + recipe.Rating.ToString();
txtSocialRank.Margin = new Thickness(10, 10, 10, 10);
txtSocialRank.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtSocialRank);
TextBlock txtPublisher = new TextBlock();
txtPublisher.Text = "Publisher: " + recipe.SourceDisplayName;
txtPublisher.Margin = new Thickness(10, 10, 10, 10);
txtPublisher.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtPublisher);
TextBlock txtTotalTime = new TextBlock();
txtTotalTime.Text = "Total Time (seconds): " + recipe.TotalTime.ToString();
txtTotalTime.Margin = new Thickness(10, 10, 10, 10);
txtTotalTime.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtTotalTime);
TextBlock txtCourse = new TextBlock();
txtCourse.Text = "Courses: " + recipe.Course;
txtCourse.Margin = new Thickness(10, 10, 10, 10);
txtCourse.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtCourse);
TextBlock txtCusine = new TextBlock();
txtCusine.Text = "Cuisine: " + recipe.Cuisine;
txtCusine.Margin = new Thickness(10, 10, 10, 10);
txtCusine.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtCusine);
TextBlock txtFlavors = new TextBlock();
//.........这里部分代码省略.........
示例3: populateRecipes
private void populateRecipes()
{
// PivotItem pvt;
int i = 0;
if (listRecipes.Count == 0)
{
PivotItem pivotItem = new PivotItem();
pivotItem.Header = "No Results";
TextBlock txtTitle = new TextBlock();
txtTitle.Text = "No Results Found";
txtTitle.Margin = new Thickness(10, 10, 10, 10);
pivotItem.Content = txtTitle;
pvtRecipes.Items.Add(pivotItem);
}
foreach (Model.ResponseYummly recipe in listRecipes)
{
PivotItem pivotItem = new PivotItem();
pivotItem.Header = recipe.RecipeName;
Grid grid = new Grid();
grid.ColumnDefinitions.Add(new ColumnDefinition());
grid.ColumnDefinitions.Add(new ColumnDefinition());
Image img = new Image();
img.Source = new BitmapImage(new Uri(recipe.ImageUrl));
img.SetValue(Grid.ColumnProperty, 0);
grid.Children.Add(img);
Image favorite = new Image();
favorite.Name = "favoriteSymbol"+i.ToString();
BitmapImage starImage = new BitmapImage();
starImage.UriSource = new Uri("https://image.freepik.com/free-icon/favorites-star-outlined-symbol_318-69168.png");
favorite.Source = starImage;
favorite.HorizontalAlignment = HorizontalAlignment.Right;
favorite.VerticalAlignment = VerticalAlignment.Top;
favorite.Width = 15;
favorite.Height = 15;
favorite.Tapped += Favorite_Tapped;
favorite.SetValue(Grid.ColumnProperty, 1);
i++;
//grid.Children.Add(favorite);
StackPanel stk = new StackPanel();
stk.Name = "recipeStk";
stk.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(favorite);
TextBlock txtTitle = new TextBlock();
txtTitle.Text = "Title: " + recipe.RecipeName;
txtTitle.Margin = new Thickness(10, 10, 10, 10);
txtTitle.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtTitle);
TextBlock txtRecipeId = new TextBlock();
txtRecipeId.Text = "RecipeId: " + recipe.Id;
txtRecipeId.Margin = new Thickness(10, 10, 10, 10);
txtRecipeId.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtRecipeId);
TextBlock txtIngredientsList = new TextBlock();
txtIngredientsList.Text = "Ingredients: " + recipe.Ingredients.Replace("\",","\n");
txtIngredientsList.Margin = new Thickness(10, 10, 10, 10);
txtIngredientsList.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtIngredientsList);
TextBlock txtSocialRank = new TextBlock();
txtSocialRank.Text = "Social Rank: " + recipe.Rating.ToString();
txtSocialRank.Margin = new Thickness(10, 10, 10, 10);
txtSocialRank.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtSocialRank);
TextBlock txtPublisher = new TextBlock();
txtPublisher.Text = "Publisher: " + recipe.SourceDisplayName;
txtPublisher.Margin = new Thickness(10, 10, 10, 10);
txtPublisher.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtPublisher);
TextBlock txtTotalTime = new TextBlock();
txtTotalTime.Text = "Total Time (seconds): " + recipe.TotalTime.ToString();
txtTotalTime.Margin = new Thickness(10, 10, 10, 10);
txtTotalTime.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtTotalTime);
TextBlock txtCourse = new TextBlock();
txtCourse.Text = "Courses: " + recipe.Course;
txtCourse.Margin = new Thickness(10, 10, 10, 10);
txtCourse.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtCourse);
TextBlock txtCusine = new TextBlock();
txtCusine.Text = "Cuisine: " + recipe.Cuisine;
txtCusine.Margin = new Thickness(10, 10, 10, 10);
txtCusine.SetValue(Grid.ColumnProperty, 1);
stk.Children.Add(txtCusine);
TextBlock txtFlavors = new TextBlock();
txtFlavors.Text = "Flavors: " + recipe.Flavors.Replace(",\"", "\n");
txtFlavors.Margin = new Thickness(10, 10, 10, 10);
//.........这里部分代码省略.........