有没有办法在运行时创建的 wpf 按钮内垂直对齐文本(即居中),我试过:
代码片段
Button btn = new Button();
Style style = this.FindResource("ButtonStyle1") as Style;
btn.Style = style;
TextBlock txtTblNme = new TextBlock();
txtTblNme.Text = Convert.ToString(Tbl.SelTblNme(i));
txtTblNme.TextAlignment = TextAlignment.Center;
txtTblNme.VerticalAlignment = VerticalAlignment.Center;
txtTblNme.HorizontalAlignment = HorizontalAlignment.Stretch;
btn.Content = txtTblNme;