本文整理汇总了C#中System.Windows.Controls.Label.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Label.SetValue方法的具体用法?C# Label.SetValue怎么用?C# Label.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.Label
的用法示例。
在下文中一共展示了Label.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeItems
public void InitializeItems(Altaxo.Collections.ListNodeList list)
{
int rowsNeeded = (list.Count + 1) >> 1;
int diff = rowsNeeded - _guiGrid.RowDefinitions.Count;
for (int i = diff - 1; i >= 0; --i)
_guiGrid.RowDefinitions.Add(new RowDefinition());
_guiGrid.Children.Clear();
int itemIdx = -1;
foreach (var t in list)
{
itemIdx++;
int column = itemIdx % 2;
int row = itemIdx >> 1;
var label = new Label() { Content = t.Text };
label.SetValue(Grid.ColumnProperty, 2 * column);
label.SetValue(Grid.RowProperty, row);
_guiGrid.Children.Add(label);
var uiElement = (FrameworkElement)t.Tag;
uiElement.SetValue(Grid.ColumnProperty, 2 * column + 1);
uiElement.SetValue(Grid.RowProperty, row);
uiElement.Margin = new Thickness(4);
_guiGrid.Children.Add(uiElement);
}
}
示例2: createGrid
public void createGrid(int x, int y)
{
Border border = new Border();
border.Background = new SolidColorBrush(Colors.Black);
levelGrid = new Grid();
level.Children.Add(levelGrid);
levelGrid.Background = new SolidColorBrush(Colors.Green);
levelGrid.Width = x * levelGridCellSize;
levelGrid.Height = y * levelGridCellSize;
levelGrid.ShowGridLines = true;
levelGrid.MouseDown += new MouseButtonEventHandler(levelGrid_MouseDown);
for (int i = 0; i < x; i++)
{
ColumnDefinition col = new ColumnDefinition();
col.Width = new GridLength(levelGridCellSize);
levelGrid.ColumnDefinitions.Add(col);
}
for (int i = 0; i < y; i++)
{
RowDefinition row = new RowDefinition();
row.Height = new GridLength(levelGridCellSize);
levelGrid.RowDefinitions.Add(row);
for (int j = 0; j < y; j++)
{
Label label = new Label();
label.Content = i + " " + j;
label.SetValue(Grid.ColumnProperty, j);
label.SetValue(Grid.RowProperty, i);
levelGrid.Children.Add(label);
}
}
}
示例3: GenereateFields
public static void GenereateFields()
{
// Get the Grid from the MainWindow
Grid AuthenticationGrid = ((MainWindow)System.Windows.Application.Current.MainWindow).AuthenticationGrid;
// Build a list of Digest Auth Fields
List<string> fields = new List<string>();
fields.Add("Username");
fields.Add("Password");
for (int i = 0; i < fields.Count; i++)
{
// Add a row to the AuthGrid
RowDefinition rowDefinition = new RowDefinition();
rowDefinition.Height = GridLength.Auto;
AuthenticationGrid.RowDefinitions.Add(rowDefinition);
// Add a Label
Label label = new Label();
label.SetValue(Grid.RowProperty, i + 1);
label.SetValue(Grid.ColumnProperty, 0);
label.Name = "AuthenticationKey" + i;
label.Content = fields[i] + ":";
AuthenticationGrid.Children.Add(label);
// Add a textbox
TextBox textBox = new TextBox();
textBox.SetValue(Grid.RowProperty, i + 1);
textBox.SetValue(Grid.ColumnProperty, 1);
textBox.Name = "AuthenticationValue" + i;
AuthenticationGrid.Children.Add(textBox);
}
}
示例4: cnvCanvas_MouseRightButtonDown
private void cnvCanvas_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
Point p = e.GetPosition(cnvCanvas);
Label l = new Label();
l.Content = "X";
l.SetValue(Canvas.LeftProperty, p.X);
l.SetValue(Canvas.TopProperty, p.Y);
cnvCanvas.Children.Add(l);
}
示例5: initEntityForm
public virtual void initEntityForm( object obj,bool AddState)
{
if (AddState == true)
{
btnAdd.Visibility = Visibility.Visible;
btnUpdate.Visibility = Visibility.Collapsed;
}
else
{
btnAdd.Visibility = Visibility.Collapsed;
btnUpdate.Visibility = Visibility.Visible;
}
Type type = obj.GetType();
//设置Title
txtEntityTitle.Text = "详情";
this.Title = type.Name;
EntityGrid.SetValue(Grid.ShowGridLinesProperty, true); //显示网格
//设置实体属性
PropertyInfo[] infos = type.GetProperties();
for (int i = 0; i < infos.Count(); i++)
{
RowDefinition row=new RowDefinition();
EntityGrid.RowDefinitions.Add(row);
PropertyInfo pinfo = infos[i];
if (pinfo.Name == "EntityKey") continue;
Label lable = new Label();
lable.Content=pinfo.Name+":";
lable.Margin = new Thickness(0, 10, 0, 0);
EntityGrid.Children.Add(lable);
lable.SetValue(Grid.ColumnProperty, 0);
lable.SetValue(Grid.RowProperty, i);
//EntityGrid.
//LeftLabelArea.Children.Add(lable);
//pinfo.Name;
//pinfo.GetValue(obj, null);
TextBox txtBox = new TextBox();
txtBox.Name = pinfo.Name.Trim();
txtBox.Margin = new Thickness(0, 10, 0, 0);
string strPinfoValue = string.Empty;
if (pinfo.GetValue(obj, null) != null)
{
strPinfoValue = pinfo.GetValue(obj, null).ToString();
}
txtBox.Text = strPinfoValue;
//RightDataArea.Children.Add(txtBox);
EntityGrid.Children.Add(txtBox);
txtBox.SetValue(Grid.ColumnProperty, 1);
txtBox.SetValue(Grid.RowProperty, i);
}
}
示例6: SetParametersSource
public void SetParametersSource(List<System.Data.OleDb.OleDbParameter> parms)
{
int nRow = -1;
foreach (var p in parms)
{
_grid.RowDefinitions.Add(new RowDefinition());
++nRow;
// create label
var lbl = new Label();
lbl.Content = CleanupName(p.ParameterName);
lbl.SetValue(Grid.RowProperty, nRow);
_grid.Children.Add(lbl);
// create input control
Control ctl = GetControl(p);
ctl.Tag = p;
ctl.SetValue(Grid.RowProperty, nRow);
ctl.SetValue(Grid.ColumnProperty, 1);
_grid.Children.Add(ctl);
if (_focus == null)
{
_focus = ctl;
}
}
}
示例7: MainWindow
public MainWindow()
{
Snowflakes = new ObservableCollection<object>();
InitializeComponent();
// Add month names to bottom.
string[] months = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
foreach ( string month in months )
{
var label = new Label { Content = month, Foreground = Brushes.White, FontSize = 14 };
label.SetValue( TimePanel.XProperty, DateTime.Parse( month + " 2015" ) );
label.SetValue( TimePanel.YProperty, Timeline.VisibleIntervalY.End );
Timeline.Children.Add( label );
}
}
示例8: showScore
private void showScore(String map)
{
//Remove all rows except for the first one. (The header row)
highScoreGrid.RowDefinitions.Clear();
highScoreGrid.Children.Clear();
highScoreGrid.RowDefinitions.Add(new RowDefinition());
highScoreGrid.Children.Add(headerPlayer);
highScoreGrid.Children.Add(headerMoves);
highScoreGrid.Children.Add(headerTimer);
//Get the highscores for the chosen map.
ModelScore[] scores = highScore.getHighScore(map).ToArray();
//Show the scores.
int rowNumber = 1;
foreach (ModelScore score in scores)
{
//Create the row
RowDefinition row = new RowDefinition();
row.Height = new GridLength(rowHeight, GridUnitType.Pixel);
highScoreGrid.RowDefinitions.Add(row);
//Add the information to the row columns..
Label player = new Label();
player.Content = score.PlayerName;
player.SetValue(Grid.ColumnProperty, 0);
player.SetValue(Grid.RowProperty, rowNumber);
highScoreGrid.Children.Add(player);
Label moves = new Label();
moves.Content = score.Moves;
moves.SetValue(Grid.ColumnProperty, 1);
moves.SetValue(Grid.RowProperty, rowNumber);
highScoreGrid.Children.Add(moves);
Label time = new Label();
time.Content = (score.Time / 60) + ":" + (score.Time % 60);
time.SetValue(Grid.ColumnProperty, 2);
time.SetValue(Grid.RowProperty, rowNumber);
highScoreGrid.Children.Add(time);
rowNumber++;
}
}
示例9: MakeSimpleLabel
public static Label MakeSimpleLabel(string text, Rect bounds, System.Windows.Media.Brush brush)
{
Label label = new Label { Content = text };
if (bounds.Width != 0)
{
label.SetValue(Canvas.LeftProperty, bounds.Left);
label.SetValue(Canvas.TopProperty, bounds.Top);
label.Width = bounds.Width;
label.Height = bounds.Height;
}
label.Foreground = brush;
label.FontFamily = new System.Windows.Media.FontFamily("Arial");
label.FontWeight = FontWeight.FromOpenTypeWeight(600);
label.FontStyle = FontStyles.Normal;
label.HorizontalAlignment = HorizontalAlignment.Center;
label.VerticalAlignment = VerticalAlignment.Center;
return label;
}
示例10: DrawLabel
public void DrawLabel(int x, int y, int width, int height, string text, Color color)
{
Label label = new Label();
label.Content = text;
label.SetValue(Canvas.LeftProperty, (double)x);
label.SetValue(Canvas.TopProperty, (double)y);
label.Background = new SolidColorBrush(Colors.Transparent);
label.Foreground = new SolidColorBrush(color);
if (label.Width > width)
{
label.Width = width;
}
//label.Width = 20;
label.Height = height;
ToolTipService.SetToolTip(label, text);
Canvas.Children.Add(label);
}
示例11: RowEditorWindow
public RowEditorWindow(ImportStagingService service, int rowId, List<ImportFieldMapping> mappings, DataRowView row)
{
InitializeComponent();
this.Service = service;
this.RowID = rowId;
this.Row = row;
this.Mappings = mappings;
int rowIndex = 0;
foreach (ImportFieldMapping mapping in mappings) {
gridFields.RowDefinitions.Add(CreateRowDefinition());
var lbl = new Label();
lbl.SetValue(Grid.RowProperty, rowIndex);
lbl.Content = mapping.SourceColumn;
gridFields.Children.Add(lbl);
var txt = new Extensibility.TextBox();
txt.SetValue(Grid.ColumnProperty, 1);
txt.SetValue(Grid.RowProperty, rowIndex);
txt.Height = 23;
var objValue = row[mapping.SourceColumn];
var strValue = (objValue == null ? "" : objValue.ToString());
var value = new FieldValue(mapping.TargetColumn, strValue);
var binding = new Binding("Value");
binding.Source = value;
binding.ValidatesOnDataErrors = true;
txt.SetBinding(TextBox.TextProperty, binding);
// txt.Text = strValue;
var fieldMapping = mapping; // need to keep a copy of this mapping so its captured in the closure
txt.TextChanged += new TextChangedEventHandler((source, e) => {
var textbox = source as TextBox;
if (textbox.Text != strValue) {
_changeMap[fieldMapping.SourceColumn] = textbox.Text;
} else {
if (_changeMap.ContainsKey(fieldMapping.SourceColumn)) {
_changeMap.Remove(fieldMapping.SourceColumn);
}
}
});
gridFields.Children.Add(txt);
rowIndex++;
}
}
示例12: SudokuSquare
public SudokuSquare(int id, int x, int y)
{
Rectangle rectangle = new Rectangle();
rectangle.Width = 40;
rectangle.Height = 37;
rectangle.SetValue(Canvas.TopProperty, Convert.ToDouble(y));
rectangle.SetValue(Canvas.LeftProperty, Convert.ToDouble(x));
GradientStopCollection gradients = new GradientStopCollection();
Label label = new Label();
label.Height = 37;
label.Width = 40;
label.FontSize = 25;
label.SetValue(Canvas.TopProperty, Convert.ToDouble(y - 5));
label.SetValue(Canvas.LeftProperty, Convert.ToDouble(x + 7));
label.Name = "B" + (id).ToString();
}
示例13: GameFrame
/// <summary>
/// 构造函数,参数为主体网格,以及行数列数
/// </summary>
/// <param name="grid"></param>
/// <param name="row"></param>
/// <param name="column"></param>
public GameFrame(Grid grid, int row, int column)
{
boxDropInterval = 500;
this.grid = grid;
this.row = row;
this.column = column;
State = GameState.Stoped;
boxNum = 0;
Hard = 1;
for (int i = 0; i < column; i++)
{
grid.ColumnDefinitions.Add(new ColumnDefinition());
}
for (int i = 0; i < row; i++)
{
grid.RowDefinitions.Add(new RowDefinition());
}
container = new Container(row, column);
boxFactory = new BoxFactory();
for (int i = 0; i < row; i++)
{
for (int j = 0; j < column; j++)
{
Label lbl = new Label();
container.map[i, j] = new GridData();
container.map[i, j].Lbl = lbl;
container.map[i, j].Value = BoxShape.NULL;
lbl.SetValue(Grid.RowProperty, i);
lbl.SetValue(Grid.ColumnProperty, j);
grid.Children.Add(lbl);
}
}
ClearMap();
}
示例14: Initialize
public void Initialize(string[] names)
{
for (int i = 0; i < names.Length; ++i)
{
RowDefinition rowDef = new RowDefinition();
rowDef.Height = new GridLength(30.0);
this.CellGrid.RowDefinitions.Add(rowDef);
Label label = new Label();
label.Content = names[i];
this.CellGrid.Children.Add(label);
label.SetValue(Grid.RowProperty, i);
label.SetValue(Grid.ColumnProperty, 0);
Label valueLabel = new Label();
this.labels.Add(valueLabel);
this.CellGrid.Children.Add(valueLabel);
valueLabel.SetValue(Grid.RowProperty, i);
valueLabel.SetValue(Grid.ColumnProperty, 1);
}
}
示例15: SetDay
private void SetDay(Grid Day,string sub,string start,string end)
{
int startidx = TimeRow.IndexOf(start);
int endidx = TimeRow.IndexOf(end) - startidx;
CreateRowDefinition(Day);
Label l = new Label();
l.Style = (Style)this.Resources["CommonLabel"];
TextBlock tb = new TextBlock();
tb.TextWrapping = TextWrapping.WrapWithOverflow;
tb.Text = sub;
l.Content = tb;
l.SetValue(Grid.RowProperty, startidx);
l.SetValue(Grid.RowSpanProperty, endidx + 1);
l.ContextMenu = (ContextMenu)this.Resources["context"];
Day.Children.Add(l);
}