I am trying to add a custom greyscale effect to an image. the effect via nuget: https://www.nuget.org/packages/GrayscaleEffect/
I am trying to add the effect to an image like so:
Image.Effect = new GrayscaleEffect { };
And I am getting an error that tells me that GrayscaleEffect is a namespace, and I can't use it like so. How can this be done?
The GrayscaleEffect
class is defined in the GrayscaleEffect
namespace:
Image.Effect = new GrayscaleEffect.GrayscaleEffect
{
DesaturationFactor = 1.0
};
As Ian reminds me, you can also add using GrayscaleEffect;
at the top of your C# file, to avoid having th explicitly mention the namespace every time you reference the class:
using System.Windows;
using System.Windows.Controls;
using GrayscaleEffect;
//...snip...
Image.Effect = new GrayscaleEffect
{
DesaturationFactor = 1.0
};
If you type GrayscaleEffect.
, with a dot or period after the namespace name, intellisense will present you with a list of the types defined in that namespace:
This is generally true, and very useful.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.