MeterialDesign WPF PackIcon绑定类型

时间:2020-10-29 09:18:49

标签: c# wpf kind

我尝试以编程方式更改Packicon的种类。

更新的问题:

现在这是我的代码:

我现在实现了接口INotifyPropertyChagned:

public partial class OwnExtendedMessageBox : Window, INotifyPropertyChanged

然后我添加了这些行

    //property of Binding changed
    public event PropertyChangedEventHandler PropertyChanged;

    protected void OnPropertyChanged(string name)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
    }

然后我这样称呼

        switch (MessageBoxIcon)
        {
            case OwnMessageBoxIcon.None:
                MessageBoxIconKind = PackIconKind.Box;
                break;
            case OwnMessageBoxIcon.Info:
                MessageBoxIconKind = PackIconKind.Information;
                break;
            case OwnMessageBoxIcon.Warning:
                MessageBoxIconKind = PackIconKind.Warning;
                break;
            case OwnMessageBoxIcon.Error:
                MessageBoxIconKind = PackIconKind.Error;
                break;
            default:
                MessageBoxIconKind = PackIconKind.Box;
                break;
        }

        OnPropertyChanged("MessageBoxIconKind");

WPF:

<materialDesign:PackIcon Kind="{Binding MessageBoxIconKind}" Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}" ...

我也用字符串尝试过,但是也没有用

0 个答案:

没有答案