I have XAML code that I use to set up a frame and frame heading like this:
<Label Text="ABC" />
<t:ContentFrame>
<Label Text="ABC" />
</t:ContentFrame>
For ContentFrame
I use a C# template here:
[Xamarin.Forms.ContentProperty("Contents")]
public class ContentFrame : CustomFrame
{
StackLayout contentStack { get; } = new StackLayout()
{
Spacing = 0,
Padding = new Thickness(0),
Orientation = StackOrientation.Vertical
};
public IList<View> Contents { get => contentStack.Children; }
public ContentFrame()
{
Content = contentStack;
HasShadow = false;
SetDynamicResource(BackgroundColorProperty, "ContentFrameBackgroundColor");
SetDynamicResource(BorderColorProperty, "ContentFrameBorderColor");
SetDynamicResource(CornerRadiusProperty, "ContentFrameCornerRadius");
}
}
Is there a way that I could combine the setting of the heading into the ContentFrame
class so the same thing could be achieved with:
<t:ContentFrame Heading="ABC">
<Label Text="ABC" />
</t:ContentFrame>
You need a Bindable property for this:
If you don't require
InotifypropertyChanged
you can removeOnHeadingChanged
(also from insideBindableProperty.Create()
, if require you can add the below declaration.