c# - WPF 材料设计绑定类型的 PackIcon 不起作用
问题描述
我尝试以编程方式更改 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}" ...
我也用字符串尝试过,但它也不起作用
解决方案
推荐阅读
- php - CS-Cart的安装卡在Creating views表上
- elasticsearch - 在elasticsearch中获取数据流时间戳元字段已被禁用错误
- gis - forge 是否允许用户集成来自 GIS 平台的坐标数据?
- django - django admin 在我没有权限的只读外键上呈现链接
- angular - 具有角度服务器端渲染的预构建页面
- javascript - 并发订单时如何查看库存数量?
- python - 从 Python 子进程调用中获取 Java Exception Socket Closed
- c# - 交换邮件使用
- python - 带有 expand() 的 Snakemake 可选输出
- micronaut - Micronaut:存在多个连接时如何在 ChannelPoolListener 中创建队列