我正在尝试在后面分配materialDesign:PackIcon代码。这是我的代码。
for (int i = 0; i<PrinterNumber; i++)
{
Button btn_Restart = new Button();
btn_Restart.Name = string.Format("PrinterRestartButtton{0}", i);
btn_Restart.Width = 50;
btn_Restart.Height = 25;
btn_Restart.VerticalAlignment = VerticalAlignment.Center;
btn_Restart.HorizontalAlignment = HorizontalAlignment.Left;
btn_Restart.Content = "Restart";
//btn_Restart.Visibility = Visibility.Hidden;
btn_Restart.Click += Btn_Restart_Click;
btn_Restart.Style = (Style) Application.Current.TryFindResource("MaterialDesignRaisedDarkButton");
Grid.SetRow(btn_Restart, i + 2);
Grid.SetColumn(btn_Restart, 10);
grd_WorkArea.Children.Add(btn_Restart);
}
如何将materialDesign:PackIcon Kind =“ Restart”应用于
btn_Restart.Content属性?
最佳答案
将Content
属性设置为PackIcon
:
btn_Restart.Content = new MaterialDesignThemes.Wpf.PackIcon
{ Kind = MaterialDesignThemes.Wpf.PackIconKind.Restart };