【发布时间】:2020-12-05 08:33:51
【问题描述】:
我有 XAML 代码,用于设置这样的框架和框架标题:
<Label Text="ABC" />
<t:ContentFrame>
<Label Text="ABC" />
</t:ContentFrame>
对于ContentFrame,我在这里使用C#模板:
[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");
}
}
有没有一种方法可以将标题的设置结合到 ContentFrame 类中,这样可以实现相同的目的:
<t:ContentFrame Heading="ABC">
<Label Text="ABC" />
</t:ContentFrame>
【问题讨论】:
标签: c# xaml xamarin xamarin.forms bindableproperty