I try to change the Kind of a Packicon programmatically.
Updated Question:
That's my code now:
I implemented the Interface INotifyPropertyChagned now:
public partial class OwnExtendedMessageBox : Window, INotifyPropertyChanged
Then I added these lines
//property of Binding changed
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string name)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
Then I call it like that
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}" ...
I also tryed it with a string, but it also doesn't worked