本文整理汇总了C#中System.Windows.Controls.Button类的典型用法代码示例。如果您正苦于以下问题:C# Button类的具体用法?C# Button怎么用?C# Button使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Button类属于System.Windows.Controls命名空间,在下文中一共展示了Button类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainTab
public MainTab(int page, TabItem newTab, Image newVerso, Image newRecto, Grid canvas, Grid vGrid, Grid rGrid, Button delBtn, ScatterView SV, ScatterViewItem si, Grid vSwipeGrid, Grid rSwipeGrid, Grid vTranslationGrid, Grid rTranslationGrid, Grid vBoxesGrid, Grid rBoxesGrid, TextBlock headerText, SurfaceWindow1.language language)
{
_page = page;
_tab = newTab;
_verso = newVerso;
_recto = newRecto;
_canvas = canvas;
_vGrid = vGrid;
_rGrid = rGrid;
_SVI = si;
_delButton = delBtn;
numFingersRecto = 0;
numFingersVerso = 0;
fingerPos = new List<Point>();
avgTouchPoint = new Point(-1, 0);
_vSwipeGrid = vSwipeGrid;
_rSwipeGrid = rSwipeGrid;
_vTranslationGrid = vTranslationGrid;
_rTranslationGrid = rTranslationGrid;
_vBoxesGrid = vBoxesGrid;
_rBoxesGrid = rBoxesGrid;
_twoPage = true;
_SV = SV;
_headerTB = headerText;
_currentLanguage = language;
_previousLanguage = _currentLanguage;
_worker = new Workers(this);
}
示例2: RepoteUnhandleException
private void RepoteUnhandleException(Exception ex)
{
Button b= new Button() ;
Window w = new Window {Width = 0x258,Height = 0x1f4,Padding = new Thickness(0x14),Title = String.Format("{0} - {1}","予期せぬエラー","TwVideoUp")};
StackPanel m = new StackPanel()
{
Orientation = Orientation.Vertical,
Children =
{
new TextBlock()
{
Text = "予期せぬエラーが発生しました。以下のStackTraceをIssueとして提出いただけると嬉しいです。(ユーザー名などが含まれている場合は伏せていただいて構いません。)",
TextWrapping = TextWrapping.Wrap
},
new TextBox()
{
Text = ex.ToString(),
IsReadOnly = true,
TextWrapping = TextWrapping.Wrap,
Margin = new Thickness(10),
MaxHeight = 380,
VerticalScrollBarVisibility = ScrollBarVisibility.Auto
},
b
},
};
b.Click += (sender, args) => Clipboard.SetText(ex.ToString());
b.Content = new TextBlock() {Text = "Copy to Clipboard."};
w.Content = m;
w.ShowDialog();
Shutdown();
}
示例3: Cabecera
public Cabecera()
{
Background = new SolidColorBrush(Colors.White);
Orientation = Orientation.Vertical;
var nombreJuego = new TextBlock { Text = "Tres en Línea", FontSize = 78, Foreground = new SolidColorBrush(Colors.Black), HorizontalAlignment = HorizontalAlignment.Center};
Children.Add(nombreJuego);
var nuevoJuego = new Button {Content = "Iniciar nuevo Juego", Background = new SolidColorBrush(Colors.Black)};
nuevoJuego.Tap += nuevoJuego_Tap;
Children.Add(nuevoJuego);
Grid resultadoGrid = new Grid{Background = new SolidColorBrush(Colors.White), ShowGridLines = false};
resultadoGrid.ColumnDefinitions.Add(new ColumnDefinition());
resultadoGrid.ColumnDefinitions.Add(new ColumnDefinition{Width = new GridLength(2, GridUnitType.Star)});
resultadoGrid.RowDefinitions.Add(new RowDefinition());
var labelResultado = new TextBlock { Text = "Resultado:", FontSize = 22, Foreground = new SolidColorBrush(Colors.Black), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center };
resultadoGrid.Children.Add(labelResultado);
Grid.SetColumn(labelResultado, 0);
resultado = new TextBlock { Text = "En proceso.", FontSize = 22, Foreground = new SolidColorBrush(Colors.Black), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center };
resultadoGrid.Children.Add(resultado);
Grid.SetColumn(resultado, 1);
Children.Add(resultadoGrid);
}
示例4: DetectionButtonsControl
public DetectionButtonsControl()
{
double imageWidth = 10;
double imageHeight = 10;
double buttonWidth;
double smallDelimiter = 6 / 100 * imageWidth;
double largeDelimiter = 8 / 100 * imageWidth;
InitializeComponent();
Button startButton = new Button();
Button nextButton = new Button();
Button backButton = new Button();
Button stopButton = new Button();
this.ButtonsStackPanel.Children.Add(startButton);
this.ButtonsStackPanel.Children.Add(nextButton);
this.ButtonsStackPanel.Children.Add(backButton);
this.ButtonsStackPanel.Children.Add(stopButton);
List<Button> buttons = new List<Button>();
buttonWidth = (imageWidth - 2 * smallDelimiter - (buttons.Count - 1) * largeDelimiter) / buttons.Count;
foreach (Button b in buttons)
{
if (buttons.IndexOf(b) == 1)
{
//b.xPos = imageWidth + smallDelimiter;
}
else
{
//b.xPos = imageWidth + largeDelimiter;
}
}
}
示例5: DockAroundTheBlock
public DockAroundTheBlock()
{
Title = "Dock Around the Block";
// 1. �г� ���� �� �ʱ�ȭ
DockPanel dock = new DockPanel();
Content = dock;
// 2. ���ϴ� �ڽ� ��ü(�̹���, ��Ʈ��, �г�..)
for (int i = 0; i < 17; i++)
{
Button btn = new Button();
btn.Content = "Button No. " + (i + 1);
//-------------------------------------------------
dock.Children.Add(btn);
btn.SetValue(DockPanel.DockProperty, (Dock)(i % 4));
DockPanel.SetDock(btn, (Dock)(i % 4));
//-------------------------------------------------
}
// dock.LastChildFill = true;
dock.LastChildFill = false;
}
示例6: RegisterTaskPanes
public void RegisterTaskPanes(Register register)
{
myAddinTaskPane = register(() =>
{
var button = new System.Windows.Controls.Button
{
Content = "Insert Quote"
};
button.Click += InsertQuote;
var host = new WpfPanelHost
{
Child = new UserControl
{
Content = new StackPanel
{
Children =
{
button
}
}
}
};
return host;
}, "Quotes!");
myAddinTaskPane.Visible = true;
myAddinTaskPane.VisibleChanged += TaskPaneVisibleChanged;
TaskPaneVisibleChanged(this, EventArgs.Empty);
}
示例7: InitializeComponent
public void InitializeComponent()
{
if (!this._contentLoaded)
{
this._contentLoaded = true;
Application.LoadComponent(this, new Uri("/TWC.OVP;component/Controls/ErrorMessageBox.xaml", UriKind.Relative));
this.LayoutRoot = (Grid) base.FindName("LayoutRoot");
this.DetailsEnabledStates = (VisualStateGroup) base.FindName("DetailsEnabledStates");
this.ErrorMessageDetailDisabled = (VisualState) base.FindName("ErrorMessageDetailDisabled");
this.ErrorMessageDetailEnabled = (VisualState) base.FindName("ErrorMessageDetailEnabled");
this.DetailsStates = (VisualStateGroup) base.FindName("DetailsStates");
this.DetailsVisible = (VisualState) base.FindName("DetailsVisible");
this.DetailsNotVisible = (VisualState) base.FindName("DetailsNotVisible");
this.BackgroundRectangle = (Rectangle) base.FindName("BackgroundRectangle");
this.InnerDialogGrid = (Grid) base.FindName("InnerDialogGrid");
this.DialogRectangle = (Rectangle) base.FindName("DialogRectangle");
this.CloseButton = (Button) base.FindName("CloseButton");
this.ErrorMessageTitleTextBlock = (TextBlock) base.FindName("ErrorMessageTitleTextBlock");
this.ErrorMessageTextBlock = (TextBlock) base.FindName("ErrorMessageTextBlock");
this.ButtonOK = (Button) base.FindName("ButtonOK");
this.Icon = (TextBlock) base.FindName("Icon");
this.SimpleErrorDetails = (Grid) base.FindName("SimpleErrorDetails");
this.ShowDetailsToggle = (TextToggleButton) base.FindName("ShowDetailsToggle");
this.DetailsTextBox = (TextBox) base.FindName("DetailsTextBox");
}
}
示例8: showPopup2_Click
private void showPopup2_Click(object sender, RoutedEventArgs e)
{
if (p.IsOpen == true)
return;
Border border = new Border();
border.BorderBrush = new SolidColorBrush(Colors.White);
border.BorderThickness = new Thickness(2.0);
StackPanel panel1 = new StackPanel();
Button button1 = new Button();
button1.Content = "Close";
button1.Margin = new Thickness(5.0);
button1.Click += new RoutedEventHandler(button1_Click);
TextBlock textblock1 = new TextBlock();
textblock1.Text = "Premi il pulsante Close";
textblock1.Margin = new Thickness(5.0);
panel1.Children.Add(textblock1);
panel1.Children.Add(button1);
border.Child = panel1;
p = new Popup();
// Imposta la proprietà Child con il border che è il contenitore principale che contiene a sua volta uno stackpanel, un textblock ed un button.
p.Child = border;
//imposta la posizione del popup
p.VerticalOffset = 100;
p.HorizontalOffset = 50;
// apre il popup
p.IsOpen = true;
}
示例9: AddCredit_Click
private void AddCredit_Click(object sender, RoutedEventArgs e)
{
Credits.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
WrapPanel wp = new WrapPanel();
Grid.SetRow(wp, Credits.RowDefinitions.Count - 1);
Credits.Children.Add(wp);
TextBox nameBox = new TextBox();
nameBox.Name = creditname;
nameBox.MinWidth = 170;
wp.Children.Add(nameBox);
Button saveButton = new Button();
saveButton.Name = savebutton;
saveButton.Height = 20;
saveButton.Width = 20;
saveButton.Margin = new Thickness(10, 0, 0, 0);
saveButton.Click += new RoutedEventHandler(saveButton_Click);
Image okImage = new Image();
okImage.Source = Helpers.BitmapSourceFromBitmap(Exp1.Properties.Resources.ok);
saveButton.Content = okImage;
wp.Children.Add(saveButton);
Button cancelButton = new Button();
cancelButton.Name = cancelbutton;
cancelButton.Height = 20;
cancelButton.Width = 20;
cancelButton.Margin = new Thickness(10, 0, 0, 0);
cancelButton.Click += new RoutedEventHandler(cancelButton_Click);
Image cancelImage = new Image();
cancelImage.Source = Helpers.BitmapSourceFromBitmap(Exp1.Properties.Resources.cancel);
cancelButton.Content = cancelImage;
wp.Children.Add(cancelButton);
}
示例10: SplitNine
public SplitNine()
{
Title = "Split Nine";
Grid grid = new Grid();
Content = grid;
// Set row and column definitions.
for (int i = 0; i < 3; i++)
{
grid.ColumnDefinitions.Add(new ColumnDefinition());
grid.RowDefinitions.Add(new RowDefinition());
}
// Create 9 buttons.
for (int x = 0; x < 3; x++)
for (int y = 0; y < 3; y++)
{
Button btn = new Button();
btn.Content = "Row " + y + " and Column " + x;
grid.Children.Add(btn);
Grid.SetRow(btn, y);
Grid.SetColumn(btn, x);
}
// Create splitter.
GridSplitter split = new GridSplitter();
split.Width = 6;
grid.Children.Add(split);
Grid.SetRow(split, 1);
Grid.SetColumn(split, 1);
}
示例11: Button
//the button constructor
public Button()
{
//initializing the button controll
mButton = new System.Windows.Controls.Button();
//set the view of the current widget as the previously instantiated button controll
View = mButton;
}
示例12: BasicsWindow
public BasicsWindow()
{
Window basics = new Window
{
Title = "Code Basics",
Height = 400,
Width = 400,
FontSize = 20,
};
StackPanel sp = new StackPanel();
basics.Content = sp;
TextBlock title = new TextBlock
{
Text = "Code Basics",
FontSize = 24,
TextAlignment = TextAlignment.Center,
};
sp.Children.Add(title);
txtName = new TextBox();
sp.Children.Add(txtName);
txtName.Margin = new Thickness(10);
Button btnSend = new Button
{
Content = "Send",
};
sp.Children.Add(btnSend);
btnSend.Margin = new Thickness(10);
btnSend.Click += BtnSend_Click;
basics.Show();
}
示例13: updateBottomText
private static void updateBottomText(Button btn, string newValue)
{
TextBlock lbl = UIHelper.GetChild<TextBlock>(btn, "PART_BottomText");
if (lbl == null)
{
ContentPresenter c = UIHelper.GetChild<ContentPresenter>(btn);
if (c != null && c.Parent is Panel)
{
Panel p = c.Parent as Panel;
lbl = new TextBlock();
lbl.Name = "PART_BottomText";
lbl.Text = newValue;
lbl.HorizontalAlignment = HorizontalAlignment.Center;
lbl.VerticalAlignment = VerticalAlignment.Bottom;
lbl.Margin = new Thickness(-10, 0, -10, -13);
updateBottomForeground(lbl, GetBottomTextForeground(btn));
p.Children.Add(lbl);
}
btn.Loaded -= btn_Loaded;
}
else
{
lbl.Text = newValue;
}
}
示例14: CreateWindowCommandRectangle
/// <summary>
/// Creates the window command rectangle.
/// </summary>
/// <param name="parentButton">The parent button.</param>
/// <param name="style">The style.</param>
/// <returns>Rectangle.</returns>
public static Rectangle CreateWindowCommandRectangle(Button parentButton, string style)
{
Argument.IsNotNull(() => parentButton);
Argument.IsNotNullOrWhitespace(() => style);
var rectangle = new Rectangle
{
Width = 16d,
Height = 16d,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Stretch = Stretch.UniformToFill
};
rectangle.SetBinding(Rectangle.FillProperty, new Binding("Foreground")
{
Source = parentButton
});
var application = Application.Current;
if (application != null)
{
rectangle.OpacityMask = new VisualBrush
{
//Stretch = Stretch.Fill,
Visual = application.FindResource(style) as Visual
};
}
return rectangle;
}
示例15: AbandonQuotePrice
public void AbandonQuotePrice(QuotePriceClient quotePrice, QuotePriceForInstrument quotePriceForInstrument, bool isSigle, Button btn)
{
if (quotePriceForInstrument != null)
{
List<Answer> quoteQuotations = new List<Answer>();
if (isSigle)
{
if (quotePrice != null)
{
quoteQuotations.Add(quotePrice.ToSendQutoPrice());
}
}
else
{
quoteQuotations = quotePriceForInstrument.GetSelectedQuotePriceForAccount();
}
if (quoteQuotations.Count > 0)
{
var AbandonQuoteEventLog = new EventLogEntity(Guid.NewGuid())
{
//write log
};
}
//Notify service
string exchangeCode = string.Empty;
ConsoleClient.Instance.AbandonQuote(quoteQuotations);
}
}