我正在尝试通过绑定设置某些图标的背景颜色,但我可能遗漏了一些东西并且不知道是什么。
xml:
<materialDesign:PackIcon x:Name="SaveIcon" Kind="ContentSave"
Height="25" Width="25" Background="{Binding Background}" />
后面的代码:
public Page6()
{
InitializeComponent();
DataContext = this;
Background = "Red";
}
private string _background;
public string Background
{
get
{
return _background;
}
set
{
_background = value;
OnPropertyChanged();
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged([CallerMemberName] string propertyName=null)
{
PropertyChanged?.Invoke(this , new PropertyChangedEventArgs(propertyName));
}
但这不是什么都不做,我的意思是没有背景颜色。