WPF材质设计绑定类型的PackIcon不起作用

时间:2020-10-29 11:44:38

标签: c# wpf binding

我尝试以编程方式更改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 个答案:

没有答案
相关问题