I’m developing a CustomRenderableSeries with several dependency properties that controls how the series is displayed. When one of these properties changes I’d like to invalidate the series and have it redraw. What’s the best way to do this?
- Paul Gotzel asked 3 years ago
- You must login to post comments
Hi Paul
There’s a static method in the BaseRenderrableSeries class called OnInvalidateParentSurface. If you set that as the property notifier then the parent surface will be invalidated.
public class MyRenderableSeries : CustomRenderableSeries
{
public static readonly DependencyProperty FooProperty = DependencyProperty.Register(
"Foo", typeof(bool), typeof(MyRenderableSeries), new PropertyMetadata(default(bool), OnInvalidateParentSurface));
public bool Foo
{
get { return (bool) GetValue(FooProperty); }
set { SetValue(FooProperty, value); }
}
}
Alternatively, if you need a bit more customisation you can create a handler like this.
public class MyRenderableSeries : CustomRenderableSeries
{
public static readonly DependencyProperty FooProperty = DependencyProperty.Register(
"Foo", typeof(bool), typeof(MyRenderableSeries), new PropertyMetadata(default(bool), MyCustomHandler));
private static void MyCustomHandler(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
// Do some logic here with d, e.
// Then call OnInvalidateParentSurface
OnInvalidateParentSurface(d, e);
}
public bool Foo
{
get { return (bool) GetValue(FooProperty); }
set { SetValue(FooProperty, value); }
}
}
Let me know if this helps!
Best regards,
Andrew
- Andrew Burnett-Thompson answered 3 years ago
- You must login to post comments
Please login first to submit.