forked from VladislavAntonyuk/MauiSamples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CardView.cs
39 lines (34 loc) · 925 Bytes
/
CardView.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma warning disable CS0169
namespace CardLayout;
using Maui.BindableProperty.Generator.Core;
using Microsoft.Maui.Controls.Shapes;
public partial class CardView : ContentView
{
private readonly VerticalStackLayout container = new();
[AutoBindable(OnChanged = nameof(UpdateView))]
private IView? cardContent;
[AutoBindable(OnChanged = nameof(UpdateView))]
private IView? footer;
[AutoBindable(OnChanged = nameof(UpdateView))]
private IView? header;
private void UpdateView(IView? oldValue, IView? newValue)
{
if (oldValue is null && newValue is not null)
{
container.Add(newValue);
var border = new Border()
{
Content = container,
StrokeShape = new RoundRectangle() { CornerRadius = new CornerRadius(10) },
StrokeThickness = 4,
Stroke = Brush.CadetBlue
};
Content = border;
}
}
public CardView()
{
container.Background = Brush.Gray;
container.Padding = 10;
}
}