I have a custom control that has a VisualElement as a property. I want to set this element in XAML referring to some other control (VisualElement) in my XAML page.
Here's Custom control:
public class BlurredImage : Image
{
public static readonly BindableProperty RootElementProperty = BindableProperty.Create(nameof(RootElement), typeof(VisualElement), typeof(BlurredImage), propertyChanged: RootElementPropertyChanged);
public VisualElement RootElement { get => (VisualElement)GetValue(RootElementProperty); set => SetValue(RootElementProperty, value); }
static void RootElementPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
// Do some process
}
}
Here's my XAML code
<StackLayout x:Name="myStackLayout">
...
</StackLayout>
<controls:BlurredImage RootElement="{Binding myStackLayout, Source={x:Reference thisPage}}" />
I want BlurredImage's RootElement as myStackLayout. How can it be done?