本文整理汇总了C#中Windows.UI.Xaml.Controls.TextBlock.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# TextBlock.SetValue方法的具体用法?C# TextBlock.SetValue怎么用?C# TextBlock.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.UI.Xaml.Controls.TextBlock
的用法示例。
在下文中一共展示了TextBlock.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainPage
public MainPage()
{
this.InitializeComponent();
initLedMatrixDevice();
for (int i = 0; i < MATRIX_SIZE; i++)
{
TextBlock tb = new TextBlock();
tb.Text = "0x00";
tb.HorizontalAlignment = HorizontalAlignment.Center;
tb.VerticalAlignment = VerticalAlignment.Center;
tb.SetValue(Grid.RowProperty, i);
tb.SetValue(Grid.ColumnProperty, MATRIX_SIZE);
_matrix.Children.Add(tb);
_matrixRowValue[i] = tb;
for (int j = 0; j < MATRIX_SIZE; j++)
{
Ellipse led = new Ellipse();
led.Width = 40;
led.Height = 40;
led.HorizontalAlignment = HorizontalAlignment.Center;
led.VerticalAlignment = VerticalAlignment.Center;
led.Fill = _off;
led.SetValue(Grid.RowProperty, i);
led.SetValue(Grid.ColumnProperty, j);
led.PointerPressed += Led_PointerPressed;
_matrix.Children.Add(led);
setMatrixData(i, j, 0);
}
}
}
示例2: CreateLabel
private TextBlock CreateLabel(string text, double top, double left)
{
TextBlock txt = new TextBlock();
txt.Text = text;
txt.FontSize = 5*Convert.ToInt32(text);
//txt.SetValue(Canvas.TopProperty, top);
//txt.SetValue(Canvas.LeftProperty, left - txt.ActualWidth / 2);
txt.SetValue(Canvas.TopProperty, top - txt.ActualHeight/2);
txt.SetValue(Canvas.LeftProperty, left);
return txt;
}
示例3: Snow
public Snow(int x, int y, int size)
{
this.tb = new TextBlock();
tb.Text = "❆";
tb.FontFamily = new FontFamily("Segoe UI Symbol");
tb.FontSize = size;
tb.Foreground = new SolidColorBrush(Windows.UI.Colors.White);
this.x = x;
this.y = y;
tb.SetValue(Canvas.LeftProperty, this.x);
tb.SetValue(Canvas.TopProperty, this.y);
}
示例4: MainPage
public MainPage()
{
this.InitializeComponent();
this.NavigationCacheMode = NavigationCacheMode.Required;
foreach (var month in _monthsList)
{
var textBlock = new TextBlock { Text = month };
textBlock.SetValue(AutomationProperties.NameProperty, month);
// ReSharper disable once PossibleNullReferenceException
this.ListBox.Items.Add(textBlock);
}
}
示例5: SetText
public static void SetText(TextBlock element, string value)
{
element.SetValue(TextProperty, value);
}
示例6: InitializeDayLabelBoxes
private void InitializeDayLabelBoxes()
{
int column = 0;
CalendarGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
foreach (var day in Enum.GetValues(typeof(DayOfWeek)))
{
//Runtime generate controls and setting style
Rectangle box = new Rectangle();
box.Style = Application.Current.Resources["CalendarLabelBox"] as Style;
box.SetValue(Grid.RowProperty, 0);
box.SetValue(Grid.ColumnProperty, column);
TextBlock textBlock = new TextBlock();
textBlock.Style = Application.Current.Resources["CalendarLabel"] as Style;
textBlock.Text = day.ToString();
//Runtime setting the control Grid.Row and Grid.Column XAML property value
textBlock.SetValue(Grid.RowProperty, 0);
textBlock.SetValue(Grid.ColumnProperty, column);
//Adding the box and the textblock control to the Grid during runtime
CalendarGrid.Children.Add(box);
CalendarGrid.Children.Add(textBlock);
column++;
}
}
示例7: creerLabel
/// <summary>
/// Cette méthode permet de créer le TextBlock composé du nom de l'équipement/de la pièce, et qui apparaît en dessous de l'icône de l'équipement/de la pièce.
/// </summary>
/// <param name="nom">Nom de l'équipement/de la pièce.</param>
/// <returns>TextBlock composé du nom.</returns>
public TextBlock creerLabel(String nom)
{
// création label : nom de l'icône
TextBlock labelIcone = new TextBlock();
labelIcone.SetValue(TextBlock.TextProperty, nom);
// police du label
labelIcone.FontFamily = new FontFamily("Segoe UI");
labelIcone.Foreground = new SolidColorBrush(Colors.Black);
labelIcone.FontSize = 24;
// positionnement du label
labelIcone.TextAlignment = TextAlignment.Center;
labelIcone.VerticalAlignment = VerticalAlignment.Center;
labelIcone.HorizontalAlignment = HorizontalAlignment.Center;
labelIcone.TextWrapping = TextWrapping.Wrap;
return labelIcone;
}
示例8: MySquare_Tapped
private void MySquare_Tapped(object sender, TappedRoutedEventArgs e)
{
Rectangle curr = (Rectangle)sender;
//tblSquare.Text = curr.Name.ToString();
//create a new textblock
//set the grid row and col properties(same as the sender)
//set the text = X or O depending
//set the font
//set the alignment
TextBlock myTblLetter = new TextBlock();
myTblLetter.Name = "tbl" + curr.Name.ToString();
//set the grid.row of the textblock equal
//to grid.row of the sender (getvalue)
//double x = (double) curr.GetValue(Grid.RowProperty);
//double y = (double)curr.GetValue(Grid.ColumnProperty);
#region add X or O textblock to the grid tapped
myTblLetter.SetValue(Grid.RowProperty, curr.GetValue(Grid.RowProperty));
myTblLetter.SetValue(Grid.ColumnProperty, curr.GetValue(Grid.ColumnProperty));
//set alignment
myTblLetter.HorizontalAlignment = HorizontalAlignment.Center;
myTblLetter.VerticalAlignment = VerticalAlignment.Center;
//set the font size to large
myTblLetter.FontSize = 42;
//myTblLetter.Name = "tbl" + curr.Name.ToString();
//add it to the grid
grdGame.Children.Add(myTblLetter); // show it on the screen
#endregion
#region switch statement to make moves
switch (currColour)
{
case "X":
curr.Fill = new SolidColorBrush(Colors.Yellow);
// set the text to X
myTblLetter.Text = "X";
currColour = "O";
break;
case "O":
curr.Fill = new SolidColorBrush(Colors.Green);
// set the text to O
myTblLetter.Text = "O";
currColour = "X";
break;
} // switch
#endregion
curr.Tapped -= MySquare_Tapped;
#region check for winning conditions
//get the sender object and find the row and column
//rectangles named RxCy
//parse the name
//
//get the string value of X
// curr.Name.Substring(1, curr.Name.IndexOf("C") - 1);
string xValue = curr.Name.Substring(1, curr.Name.IndexOf("C") - 1);
int iRow = Convert.ToInt32(xValue);
int iCol = Convert.ToInt32(curr.Name.Substring(curr.Name.IndexOf("C") + 1));
//got row and column
//figure out the if statement to check a row
//create a method to check rows and collumns
//checkRow();
/* for (int i = 0; i <= 2; i++)
{
if (grdGame.FindName("tblR" + iRow.ToString() + "C" + i.ToString) != null)
{
// found a textblock, so compare
}
}*/
/*
if(rowArray[iRow] == 3)
{
//winner
}
*/
#endregion
}
示例9: PopulateData
private async void PopulateData()
{
if (DataSource == null)
return;
ChartCanvas.Children.Clear();
await Task.Delay(50); // raceeee... wrooom!
var margin = 10;
var values = DataSource;
if (values.Count == 0)
return;
var nonZeroValuesCount = values.Count(i => i != 0);
var maxWidth = ChartCanvas.ActualWidth - _lineThickness*3/4*nonZeroValuesCount - margin*2;
var height = 0; //(ChartCanvas.ActualHeight / 2) ;
var all = values.Aggregate(0.0f, (current, value) => current + value);
double currX = _lineThickness/2 + margin/2, offset;
var currColor = 0;
var labels = new Dictionary<double, float>();
float totalPercentage = 0;
float percentage;
ChartCanvas.Children.Add(new Line
{
X1 = currX,
X2 = ChartCanvas.ActualWidth - margin*2,
Y1 = height,
Y2 = height,
Stroke = B2,
Fill = B2,
StrokeThickness = 40,
StrokeDashCap = PenLineCap.Round,
StrokeStartLineCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Round
});
foreach (var value in values)
{
if (value == 0)
{
currColor++;
continue;
}
percentage = value*100/all;
totalPercentage += percentage;
offset = percentage*maxWidth/100;
labels.Add(currX + offset, totalPercentage);
var line = new Line
{
X1 = currX,
X2 = currX + offset,
Y1 = height,
Y2 = height,
Stroke = new SolidColorBrush(ColorsOrder[currColor]),
Fill = B2,
StrokeThickness = _lineThickness,
StrokeDashCap = PenLineCap.Round,
StrokeStartLineCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Round
};
line.PointerEntered += LineOnPointerEntered;
line.PointerExited += LineOnPointerExited;
ChartCanvas.Children.Add(line);
currX += offset + _lineThickness*3/4;
currColor++;
}
int? prevLabel = null;
foreach (var label in labels)
{
if ((int) Math.Ceiling(label.Value) == 100)
break;
var txt = new TextBlock
{
Text = Math.Floor(label.Value) + "%",
TextAlignment = TextAlignment.Center
};
var lblHeight = height + 30;
if (prevLabel == null || Math.Abs((int) label.Key - (int) prevLabel) > 30)
prevLabel = (int) label.Key;
else
lblHeight -= 80;
txt.SetValue(Canvas.TopProperty, lblHeight);
txt.SetValue(Canvas.LeftProperty, label.Key);
ChartCanvas.Children.Add(txt);
}
}
示例10: InitializeFeaturePage
void InitializeFeaturePage(Grid grid, DependencyProperty chooserProperty, TypographyFeaturePage page)
{
if (page == null)
{
grid.Children.Clear();
grid.RowDefinitions.Clear();
}
else
{
// Get the property value and metadata.
object value = GetValue(chooserProperty);
var metadata = (TypographicPropertyMetadata)chooserProperty.GetMetadata(typeof(FontChooser));
// Look up the sample text.
string sampleText = (metadata.SampleTextTag != null) ? LookupString(metadata.SampleTextTag) :
_defaultSampleText;
if (page == _currentFeaturePage)
{
// Update the state of the controls.
for (int i = 0; i < page.Items.Length; ++i)
{
// Check the radio button if it matches the current property value.
if (page.Items[i].Value.Equals(value))
{
var radioButton = (RadioButton)grid.Children[i * 2];
radioButton.IsChecked = true;
}
// Apply properties to the sample text block.
var sample = (TextBlock)grid.Children[i * 2 + 1];
sample.Text = sampleText;
ApplyPropertiesToObjectExcept(sample, chooserProperty);
sample.SetValue(metadata.TargetProperty, page.Items[i].Value);
}
}
else
{
grid.Children.Clear();
grid.RowDefinitions.Clear();
// Add row definitions.
for (int i = 0; i < page.Items.Length; ++i)
{
var row = new RowDefinition();
row.Height = GridLength.Auto;
grid.RowDefinitions.Add(row);
}
// Add the controls.
for (int i = 0; i < page.Items.Length; ++i)
{
string tag = page.Items[i].Tag;
var radioContent = new TextBlock(new Run(LookupString(tag)));
radioContent.TextWrapping = TextWrapping.Wrap;
// Add the radio button.
var radioButton = new RadioButton();
radioButton.Name = tag;
radioButton.Content = radioContent;
radioButton.Margin = new Thickness(5.0, 0.0, 0.0, 0.0);
radioButton.VerticalAlignment = VerticalAlignment.Center;
Grid.SetRow(radioButton, i);
grid.Children.Add(radioButton);
// Check the radio button if it matches the current property value.
if (page.Items[i].Value.Equals(value))
{
radioButton.IsChecked = true;
}
// Hook up the event.
radioButton.Checked += featureRadioButton_Checked;
// Add the block with sample text.
var sample = new TextBlock(new Run(sampleText));
sample.Margin = new Thickness(5.0, 5.0, 5.0, 0.0);
sample.TextWrapping = TextWrapping.WrapWithOverflow;
ApplyPropertiesToObjectExcept(sample, chooserProperty);
sample.SetValue(metadata.TargetProperty, page.Items[i].Value);
Grid.SetRow(sample, i);
Grid.SetColumn(sample, 1);
grid.Children.Add(sample);
}
// Add borders between rows.
for (int i = 0; i < page.Items.Length; ++i)
{
var border = new Border();
border.BorderThickness = new Thickness(0.0, 0.0, 0.0, 1.0);
border.BorderBrush = SystemColors.ControlLightBrush;
Grid.SetRow(border, i);
Grid.SetColumnSpan(border, 2);
grid.Children.Add(border);
}
}
}
_currentFeature = chooserProperty;
_currentFeaturePage = page;
//.........这里部分代码省略.........
示例11: LcdPrint
//.........这里部分代码省略.........
element.Tapped += async (s, a) => await mainPage.SendEvent(s, a, "tapped");
break;
}
case "LINE":
{
var line = new Line
{
X1 = lcdt.X.Value,
Y1 = lcdt.Y.Value,
X2 = lcdt.X2.Value,
Y2 = lcdt.Y2.Value,
StrokeThickness = lcdt.Width ?? 1,
Stroke = foreground
};
element = line;
break;
}
case "INPUT":
{
element = new TextBox
{
Text = lcdt.Message,
FontSize = lcdt.Size ?? DefaultFontSize,
TextWrapping = TextWrapping.Wrap,
Foreground = textForgroundBrush,
AcceptsReturn = lcdt.Multi ?? false
};
expandToEdge = true;
element.SetValue(Canvas.LeftProperty, lcdt.X);
element.SetValue(Canvas.TopProperty, lcdt.Y);
element.LostFocus += async (s, a) => await mainPage.SendEvent(s, a, "lostfocus", lcdt, ((TextBox)s).Text);
((TextBox)element).TextChanged += async (s, a) => await mainPage.SendEvent(s, a, "changed", lcdt, ((TextBox)s).Text);
break;
}
case "CHANGE":
{
var retrievedElement = GetId(lcdt.Pid.Value);
if (retrievedElement != null)
{
if (lcdt.ARGB != null)
{
var i = 0;
}
}
break;
}
case "RECTANGLE":
{
var rect = new Rectangle
{
Tag = lcdt.Tag,
Fill = backgroundBrush ?? gray
};
if (lcdt.Width.HasValue)
{
rect.Width = lcdt.Width.Value;
}
示例12: 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);
//.........这里部分代码省略.........
示例13: SetText
public static void SetText(TextBlock element, string value)
{
if(element != null)
{
element.SetValue(ArticleContentProperty, value);
}
}
示例14: ReceivedMessageCallbackWhenSubscribed
private void ReceivedMessageCallbackWhenSubscribed(string result)
{
if (!string.IsNullOrEmpty(result) && !string.IsNullOrEmpty(result.Trim()))
{
List<object> deserializedMessage = pubnub.JsonPluggableLibrary.DeserializeToListOfObject(result);
if (deserializedMessage != null && deserializedMessage.Count > 0)
{
object subscribedObject = (object)deserializedMessage[0];
if (subscribedObject != null)
{
string serializedResultMessage = pubnub.JsonPluggableLibrary.SerializeToJsonString(subscribedObject);
RTPMServer rtpmServer = JsonConvert.DeserializeObject<RTPMServer>(serializedResultMessage);
Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => {
ctd = grid.RowDefinitions.Count;
grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(columnHeight) });
TextBlock t = new TextBlock();
t.HorizontalAlignment = HorizontalAlignment.Left;
t.FontSize = 11;
t.Text = rtpmServer.Date.ToLocalTime().ToString();
t.SetValue(Grid.ColumnProperty, 0);
t.SetValue(Grid.RowProperty, ctd);
grid.Children.Add(t);
TextBlock tS = new TextBlock();
tS.HorizontalAlignment = HorizontalAlignment.Left;
tS.FontSize = 12;
tS.Text = rtpmServer.ServerName;
tS.SetValue(Grid.ColumnProperty, 1);
tS.SetValue(Grid.RowProperty, ctd);
grid.Children.Add(tS);
TextBlock tC = new TextBlock();
tC.HorizontalAlignment = HorizontalAlignment.Center;
tC.FontSize = 14;
tC.Text = rtpmServer.CPUUsage.ToString("###.##") + " %";
tC.SetValue(Grid.ColumnProperty, 2);
tC.SetValue(Grid.RowProperty, ctd);
grid.Children.Add(tC);
TextBlock tR = new TextBlock();
tR.HorizontalAlignment = HorizontalAlignment.Center;
tR.FontSize = 14;
tR.Text = rtpmServer.RAMUsage.ToString() + " Mb";
tR.SetValue(Grid.ColumnProperty, 3);
tR.SetValue(Grid.RowProperty, ctd);
grid.Children.Add(tR);
ctd++;
}).GetResults();
}
}
}
mrePubNub.Set();
}
示例15: SetWikiText
public static void SetWikiText(TextBlock wb, string html)
{
wb.SetValue(WikiTextProperty, html);
}