Hi,
i'm using RadBusyIndicator to show "sub views" in our applications main window as BusyContent using BusyContentTemplate and it works.
The problem that i'm having is that the content presenter has locally assigned margin value that i haven't succeeded to override.
What i've tried?
1.) Tried to override the margin with implicit style in resources of RadBusyIndicator with no luck (not also preferred method because of all child content presenters get affected)
2.) Wrote a new custom control that derives from RadBusyIndicator and gave it a "NewMargin" dependency property of type Thickness. When the value of "NewMargin" changes i use VisualTreeHelpers to get the content presenter from visual tree and assing the new value to content presenter, but somehow it doesn't work either. The value gets set but the the view doesn't reflect the change.
The derived indicator:
public class AdaBusyIndicator : RadBusyIndicator
{
public static readonly DependencyProperty NewMarginProperty =
DependencyProperty.Register("NewMargin", typeof(Thickness),
typeof(AdaBusyIndicator), new UIPropertyMetadata(new Thickness(), NewMarginPropertyChanged));
private static void NewMarginPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is AdaBusyIndicator abi && VisualTreeHelpers.FindChild<Border>(abi, "Indicator") is Border brd &&
VisualTreeHelpers.FindChild<ContentPresenter>(brd) is ContentPresenter cpres && e.NewValue is Thickness newThickness)
{
Thickness thickness = new Thickness(newThickness.Left, newThickness.Top, newThickness.Right, newThickness.Bottom);
cpres.Margin = thickness;
}
}
public Thickness NewMargin
{
get
{
return (Thickness)GetValue(NewMarginProperty);
}
set
{
SetValue(NewMarginProperty, value);
}
}
}