我刚刚开始学习WPF和XAML,并对如何在XAML中操作属性感到好奇。我仍然在努力学习一些基础知识,比如转换器和绑定等等。我可以用本机C#做的一件非常好的事情就是创建扩展方法来简化某些任务。我想知道是否可以为XAML创建类似的东西。使用C#扩展方法,我创建了两个函数来修改颜色-- "MakeLighter“和"MakeDarker”。这些都是难以置信的方便,很容易调整颜色的阴影。例如,我可以写:
var myBackgroundColor = Color.AntiqueWhite.MakeLighter(0.10); // Makes color 10% lig
我还发现它无法识别BaseColor,因为当我使用System.out.println检查BaseColor的“红色”通道时,它给了我一个零,而应该是255。(颜色是白色。)int FillRed, int FillGreen, int FillBlue, int FillAlpha, int Tolerance, boolean IsFirstPixel, Color BaseColor) { BaseColor = new Color(RG