Это страница XAML:
Код: Выделить всё
Код: Выделить всё
Код: Выделить всё
public Selector(string Title, List Content)
{
InitializeComponent();
ItemTitle.Text = Title;
ControlTemplate? style = Resources["SelectorRadioButton"] as ControlTemplate;
for (int i = 0; i < Content.Count; i++)
{
var (icon, title, desc) = Content[i];
Grid tile = new()
{
ColumnDefinitions =
{
new ColumnDefinition() { Width = GridLength.Auto },
new ColumnDefinition() { Width = GridLength.Star }
},
RowDefinitions =
{
new RowDefinition() { Height = GridLength.Auto },
new RowDefinition() { Height = GridLength.Auto }
},
Margin = new Thickness(5)
};
Label titleLabel = new()
{
Text = title,
FontSize = 20,
FontAttributes = FontAttributes.Bold
};
tile.Add(titleLabel,1,0);
Label descriptionLabel = new()
{
Text = desc,
FontSize = 16,
};
tile.Add(descriptionLabel,1,1);
Image iconImage = new()
{
Source = icon,
WidthRequest = 56,
HeightRequest = 56,
Margin = new Thickness(5)
};
iconImage.Behaviors.Add(new IconTintColorBehavior { TintColor = GSettings.DarkMode ? Colors.White : Colors.Black });
tile.Add(iconImage,0,0);
tile.SetRowSpan(iconImage,2);
SelectorRadio radio = new()
{
Margin = new Thickness(0,5),
Padding = new Thickness(10,5),
Content = tile,
HorizontalOptions = LayoutOptions.Fill,
ControlTemplate = style,
Current = i
};
ItemStack.Add(radio);
}
}