设置材料设计:PackIcon代码背后

时间:2019-03-29 08:48:27

标签: c# wpf button material-design

我正在尝试在后面分配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属性?

1 个答案:

答案 0 :(得分:2)

Content属性设置为PackIcon

btn_Restart.Content = new MaterialDesignThemes.Wpf.PackIcon 
    { Kind = MaterialDesignThemes.Wpf.PackIconKind.Restart };