Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,784 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I need to create two textblocks in the button control, but, I can't. Who can teach me? I need c# code. Thanks!
My code:
Button btn_Click = new Button();
btn_Click.Name = "Btn_1";
btn_Click.Height = 100;
I think it like this:
private void AddControls()
{
TextBlock textBlock1 = new TextBlock { Text = "Text 1", Width = 100, Height = 25};
TextBlock textBlock2 = new TextBlock { Text = "Text 2", Width = 100, Height = 25 };
StackPanel stackPanel = new StackPanel();
stackPanel.Children.Add(textBlock1);
stackPanel.Children.Add(textBlock2);
Button button = new Button { Width = 250, Height = 60 };
button.Content = stackPanel;
gridMain.Children.Add(button);
}