本文整理汇总了C#中Button.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Button.SetValue方法的具体用法?C# Button.SetValue怎么用?C# Button.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Button
的用法示例。
在下文中一共展示了Button.SetValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddButtons
private void AddButtons(int count)
{
for (int i = 0; i < count; i++)
{
this.GameBoard.ColumnDefinitions.Add(new ColumnDefinition());
this.GameBoard.RowDefinitions.Add(new RowDefinition());
}
Button button;
for (int x = 0; x < count; x++)
{
for (int y = 0; y < count; y++)
{
button = new Button();
button.HorizontalAlignment = HorizontalAlignment.Stretch;
button.VerticalAlignment = VerticalAlignment.Stretch;
button.SetValue(Grid.ColumnProperty, x);
button.SetValue(Grid.RowProperty, y);
Thickness margin = new Thickness(10);
button.Margin = margin;
this.GameBoard.Children.Add(button);
}
}
}
示例2: 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();
}
示例3: add
private void add(Grid grid, int column)
{
Button button = new Button()
{
Height = 80,
Width = 20,
FontSize = 10,
Padding = new Thickness(0),
Content = notes.Keys.ElementAt(column)
};
button.Click += (object sender, RoutedEventArgs e) =>
{
button = (Button)sender;
int note = Grid.GetColumn(button);
play(notes[notes.Keys.ElementAt(note)]);
};
button.SetValue(Grid.ColumnProperty, column);
grid.Children.Add(button);
}
示例4: SetTable
private void SetTable()
{
this.Phases.Children.Clear();
this.Phases.RowDefinitions.Clear();
this.Phases.ColumnDefinitions.Clear();
var countCol = this.TemperaturesModels.First().FirstSystem.Phases.Count;
countCol += this.TemperaturesModels.First().SecondSystem.Phases.Count;
countCol++;
for (int i = 0; i < countCol; i++)
{
this.Phases.ColumnDefinitions.Add(new ColumnDefinition(){Width = new GridLength(50)});
}
this.Phases.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(40) });
foreach (var model in this.TemperaturesModels)
{
this.Phases.RowDefinitions.Add(new RowDefinition(){Height = new GridLength(25)});
}
this.Phases.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(25) });
this.Phases.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(25) });
this.Phases.RowDefinitions.Add(new RowDefinition());
this.SetTitle("Фазовый состав в интервале температур", countCol);
this.AddTextBlockInGrid("Temp", 1, 0, 1, 3, HorizontalAlignment.Center, true);
this.AddTextBlockInGrid(this.TemperaturesModels.First().FirstSystem.Formula, 1, 1, this.TemperaturesModels.First().FirstSystem.Phases.Count, 1, HorizontalAlignment.Center, true);
this.AddTextBlockInGrid(this.TemperaturesModels.First().SecondSystem.Formula, 1, 1 + this.TemperaturesModels.First().FirstSystem.Phases.Count, this.TemperaturesModels.First().SecondSystem.Phases.Count, 1, HorizontalAlignment.Center, true);
var currentColumn = 1;
foreach (var model in this.TemperaturesModels.First().FirstSystem.Phases)
{
this.AddTextBlockInGrid(model.Phase.Formula, 2, currentColumn, 1, 1, HorizontalAlignment.Center, true);
currentColumn++;
}
foreach (var model in this.TemperaturesModels.First().SecondSystem.Phases)
{
this.AddTextBlockInGrid(model.Phase.Formula, 2, currentColumn, 1, 1, HorizontalAlignment.Center, true);
currentColumn++;
}
var currentRow = 3;
foreach (var model in this.TemperaturesModels)
{
currentColumn = 0;
this.AddTextBlockInGrid(model.Temperature.ToString(), currentRow, currentColumn, 1, 1, HorizontalAlignment.Left, true);
currentColumn++;
foreach (var phase in model.FirstSystem.Phases)
{
this.AddTextBoxInGrid(currentRow, currentColumn, phase);
currentColumn++;
}
foreach (var phase in model.SecondSystem.Phases)
{
this.AddTextBoxInGrid(currentRow, currentColumn, phase);
currentColumn++;
}
currentRow++;
}
var backButton = new Button();
backButton.Content = "Назад";
backButton.Width = 145;
backButton.Height = 30;
backButton.FontSize = 18;
backButton.Margin = new Thickness(0, 20, 0, 0);
backButton.Click += BackToTemp;
backButton.SetValue(Grid.RowProperty, currentRow);
backButton.SetValue(Grid.ColumnProperty, 1);
backButton.SetValue(Grid.ColumnSpanProperty, 3);
this.Phases.Children.Add(backButton);
var button = new Button();
button.Content = "Рассчитать";
button.Width = 145;
button.Height = 30;
button.FontSize = 18;
button.Margin = new Thickness(0, 20, 0, 0);
button.Click += PhaseGo;
button.SetValue(Grid.RowProperty, currentRow);
button.SetValue(Grid.ColumnProperty, countCol - 3);
button.SetValue(Grid.ColumnSpanProperty, 3);
this.Phases.Children.Add(button);
}
示例5: CreateButtons
private void CreateButtons ()
{
prevButton = new Button (silver);
nextButton = new Button (silver);
prevButton.Text = "Previous";
prevButton.SetValue (Canvas.TopProperty, 370);
prevButton.SetValue (Canvas.LeftProperty, 20);
prevButton.Clicked += OnPrevClicked;
prevButton.Disabled = true;
nextButton.Text = "Next";
nextButton.SetValue (Canvas.TopProperty, 370);
nextButton.SetValue (Canvas.LeftProperty, 170);
nextButton.Clicked += OnNextClicked;
nextButton.Disabled = true;
silver.Canvas.Children.Add (prevButton);
silver.Canvas.Children.Add (nextButton);
}