I have a WPF UserControl which implements ISlider with some CustomEvent (see previous episode Why I cannot compile a Custom Event declared in a Class Interface in C# ).
Now my problem is the code below doesn’t want to compile :
ISlider ISlider;
ISlider = slider as ISlider;
if (ISlider != null)
{
ISlider.CustomEvent += new CustomEvent(OnCustomEvent);
}
else
{
this.slider.ValueChanged += new RoutedPropertyChangedEventHandler<double>(this.slider_ValueChanged);
}
because UserControls don’t have a ValueChanged Event like WPF standard controls do.
So the line:
this.slider.ValueChanged += new RoutedPropertyChangedEventHandler<double>(this.slider_ValueChanged);
doesn’t compile.
So am I obliged to artificially create a ValueChanged event in my ISlider interface when I have no use of it, just to satisfy the compiler ?
Yes.