本文整理汇总了C#中System.Windows.Controls.TextBlock.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# TextBlock.SetValue方法的具体用法?C# TextBlock.SetValue怎么用?C# TextBlock.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.TextBlock
的用法示例。
在下文中一共展示了TextBlock.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnApplyTemplate
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
LayoutGrid = GetTemplateChild(PART_LayoutGrid) as Grid;
if (LayoutGrid != null)
{
if (Orientation == System.Windows.Controls.Orientation.Vertical)
{
LayoutGrid.RowDefinitions.Add(new RowDefinition(){ Height = new GridLength(0, GridUnitType.Auto)});
LayoutGrid.RowDefinitions.Add(new RowDefinition(){ Height = new GridLength(0, GridUnitType.Auto)});
}
else
{
LayoutGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(0, GridUnitType.Auto) });
LayoutGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(0, GridUnitType.Auto) });
}
}
LabelTextElement = GetTemplateChild(PART_LabelTextElement) as TextBlock;
if (LabelTextElement != null)
{
if (Orientation == System.Windows.Controls.Orientation.Vertical)
{
LabelTextElement.SetValue(Grid.RowProperty, 1);
}
else
{
LabelTextElement.SetValue(Grid.ColumnProperty, 1);
}
}
}
示例2: UpdateBarcodes
private void UpdateBarcodes(TextBlock barcodeText)
{
grid.Children.Clear();
double width = (fixedPage.Width - fixedPage.Margin.Left*2) / totalColumns;
double height = (fixedPage.Height-fixedPage.Margin.Top*2) / totalRows;
for (int i = 0; i < totalRows; i++)
{
grid.RowDefinitions[i].Height = new GridLength(height);
}
for (int j = 0; j < totalColumns; j++)
{
grid.ColumnDefinitions[j].Width = new GridLength(width);
}
for (int i = 0; i < totalRows; i++)
{
for (int j = 0; j < 6; j++)
{
var tb = new TextBlock
{
//Margin = barcodeText.Margin,
Text = barcodeText.Text,
FontFamily = barcodeText.FontFamily,
FontSize = barcodeText.FontSize
};
tb.HorizontalAlignment = HorizontalAlignment.Center;
tb.VerticalAlignment = VerticalAlignment.Center;
tb.SetValue(Grid.ColumnProperty, j);
tb.SetValue(Grid.RowProperty, i);
grid.Children.Add(tb);
}
}
}
示例3: CenterTextBlock
public static void CenterTextBlock (TextBlock blk, FrameworkElement element)
{
double x = (element.Width - blk.ActualWidth) / 2;
double y = (element.Height - blk.ActualHeight) / 2;
blk.SetValue (Canvas.TopProperty, y);
blk.SetValue (Canvas.LeftProperty, x);
}
示例4: setLabel
public static TextBlock setLabel( string text, int row, int col )
{
TextBlock label = new TextBlock();
label.Text = text;
label.Margin = new Thickness( 5, 1, 1, 1 );
label.SetValue( Grid.ColumnProperty, col );
label.SetValue( Grid.RowProperty, row );
return label;
}
示例5: PlaceTextboxPrimitive
public static TextBlock PlaceTextboxPrimitive(Grid Container, int Col, int Row)
{
TextBlock textBlock = new TextBlock();
textBlock.SetValue(Grid.ColumnProperty, Col);
textBlock.SetValue(Grid.RowProperty, Row);
textBlock.Style = (Style)Application.Current.Resources["CellTextBlock"];
Container.Children.Add(textBlock);
return textBlock;
}
示例6: GenerateTypeText
private static TextBlock GenerateTypeText(ref Thickness margin, int row, string value)
{
TextBlock elevalue = new TextBlock();
elevalue.Text = value;
elevalue.SetValue(Grid.RowProperty, row);
elevalue.SetValue(Grid.ColumnProperty, 1);
elevalue.Margin = margin;
elevalue.MinWidth = 100;
elevalue.Background = Brushes.AntiqueWhite;
return elevalue;
}
示例7: CreateLabel
private TextBlock CreateLabel(string text, double top, double left)
{
TextBlock block = new TextBlock();
block.Text=text;
SolidColorBrush brush = new SolidColorBrush();
brush.Color=Color.FromArgb(0xff, 0xf7, 0xf9, 250);
block.Foreground=brush;
block.FontSize=13.0;
block.SetValue(Canvas.TopProperty, top);
block.SetValue(Canvas.LeftProperty, left - (block.ActualWidth / 2.0));
return block;
}
示例8: MostrarGrade
private void MostrarGrade()
{
TxtCurso.Text = Context.Grade.NomeCurso;
TxtDia.Text = Context.Grade.NomeDia;
TxtSemestre.Text = Context.Grade.NumeroSemestre.ToString();
for (int i = 0; i < Context.Grade.Horarios.Count; i++)
{
if (i > 0 && Context.Grade.Horarios[i].HorarioInicial != Context.Grade.Horarios[i - 1].HorarioFinal)
{
Tabela.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
var intervalo = new TextBlock()
{
Text = "Intervalo",
TextAlignment = System.Windows.TextAlignment.Center,
Background = Brushes.LightGray,
Width = Tabela.Width,
VerticalAlignment = System.Windows.VerticalAlignment.Center,
HorizontalAlignment = System.Windows.HorizontalAlignment.Center
};
intervalo.SetValue(Grid.ColumnSpanProperty, 2);
intervalo.SetValue(Grid.RowProperty, Tabela.RowDefinitions.Count - 1);
Tabela.Children.Add(intervalo);
}
Tabela.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50) });
var horario = new TextBlock()
{
Text = string.Concat(Context.Grade.Horarios[i].HorarioInicial, " - ", Context.Grade.Horarios[i].HorarioFinal),
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center
};
horario.SetValue(Grid.ColumnProperty, 0);
horario.SetValue(Grid.RowProperty, Tabela.RowDefinitions.Count - 1);
var materia = new StackPanel()
{
Orientation = Orientation.Vertical,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center
};
if (Context.Grade.Horarios[i].Materia != null)
{
materia.Children.Add(new TextBlock() { Text = Context.Grade.Horarios[i].Materia.Materia, FontWeight = FontWeight.FromOpenTypeWeight(600) });
materia.Children.Add(new TextBlock() { Text = Context.Grade.Horarios[i].Materia.Professor });
}
materia.SetValue(Grid.ColumnProperty, 1);
materia.SetValue(Grid.RowProperty, Tabela.RowDefinitions.Count - 1);
Tabela.Children.Add(horario);
Tabela.Children.Add(materia);
}
}
示例9: AddNewRow
public void AddNewRow(int Row, string Caption)
{
System.Windows.Controls.TextBlock tb = new TextBlock();
tb.SetValue(Grid.RowProperty,Row);
tb.SetValue(Grid.ColumnProperty,0);
tb.Text = Caption;
System.Windows.Controls.TextBox txtbx = new TextBox();
txtbx.SetValue(Grid.RowProperty,Row);
txtbx.SetValue(Grid.ColumnProperty,1);
ControlGrid.Children.Add(tb);
ControlGrid.Children.Add(txtbx);
}
示例10: DrawNoteNames
private void DrawNoteNames()
{
for (int note = 0; note < pattern.Notes; note++)
{
var tb = new TextBlock();
tb.Text = pattern.NoteNames[note];
tb.SetValue(Canvas.LeftProperty, 0.0);
tb.SetValue(Canvas.TopProperty, note * gridSquareWidth);
tb.Foreground = Brushes.Gray;
tb.FontFamily = new FontFamily("Segoe UI");
tb.FontSize = 12;
drumGridCanvas.Children.Add(tb);
}
}
示例11: AddUI
public override void AddUI(Grid grid)
{
if (Config != null && Config.ShownAtRunTime)
{
TextBlock tb = new TextBlock()
{
Text = Resources.Strings.ZoomToExtentInput,
Margin = new System.Windows.Thickness(2)
};
tb.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
tb.SetValue(Grid.ColumnProperty, 1);
tb.SetValue(ToolTipService.ToolTipProperty, Config.ToolTip);
grid.Children.Add(tb);
}
}
示例12: CreateImage
private void CreateImage()
{
_adornment = new TextBlock();
_adornment.Text = "Generated";
_adornment.FontSize = 75;
_adornment.FontWeight = FontWeights.Bold;
_adornment.Foreground = Brushes.Gray;
_adornment.ToolTip = "Click to toggle visibility";
_adornment.Opacity = _currentOpacity;
_adornment.SetValue(TextOptions.TextRenderingModeProperty, TextRenderingMode.Aliased);
_adornment.SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Ideal);
_adornment.MouseEnter += (s, e) => { _adornment.Opacity = 1; };
_adornment.MouseLeave += (s, e) => { _adornment.Opacity = _currentOpacity; };
_adornment.MouseLeftButtonUp += (s, e) => { LogoAdornment.OnVisibilityChanged(_currentOpacity == 0); };
}
示例13: Week
public Week()
{
InitializeComponent();
for (int h = 0; h < 25; h++) {
// labels
TextBlock tb = new TextBlock();
if (h < 24)
tb.Text = h.ToString();
else
tb.Text = "All Day";
tb.SetValue(Grid.ColumnProperty, h + 1);
tb.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
grMain.Children.Add(tb);
if (!DesignerProperties.GetIsInDesignMode(new DependencyObject()))
for (int d = 0; d < 8; d++) {
if (h < 24 || d < 7) { // excluding h = 24 and d = 7
Day day = new Day();
day.SetValue(Grid.RowProperty, d + 1);
day.SetValue(Grid.ColumnProperty, h + 1);
day.DataContext = ((ViewModels.MainViewModel)Application.Current.MainWindow.DataContext).DayViewModels[d, h]; // if d == 8 then all days
grMain.Children.Add(day);
}
}
}
}
示例14: MainWindow
public MainWindow()
{
InitializeComponent();
var button = new Button{Content = "This is a button"};
var textBlock = new TextBlock{Text="Test"};
button.SetValue(Grid.ColumnProperty, 0);
button.SetValue(Grid.RowProperty, 0);
textBlock.SetValue(Grid.ColumnProperty, 1);
textBlock.SetValue(Grid.RowProperty, 0);
TheGrid.Children.Add(button);
TheGrid.Children.Add(textBlock);
//TheOrderedStackPanel.Order();
}
示例15: Canvas_Loaded
public void Canvas_Loaded (object sender, EventArgs e)
{
TextBlock n = new TextBlock ();
n.Text = "I am the textblock";
n.SetValue (TextBlock.ForegroundProperty, "#FF626262");
Children.Add (n);
}