You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.7 KiB

namespace AMC.View.Controls
{
public partial class LibraryCategoryItem : ContentView
{
public static readonly BindableProperty CategoryTextProperty = BindableProperty.Create(
propertyName: nameof(CategoryText),
returnType: typeof(string),
declaringType: typeof(LibraryCategoryItem),
defaultValue: "",
propertyChanged: CategoryTextChanged
);
public static readonly BindableProperty IconSourceProperty = BindableProperty.Create(
propertyName: nameof(IconSource),
returnType: typeof(ImageSource),
declaringType: typeof(LibraryCategoryItem),
defaultValue: null,
propertyChanged: IconSourceChanged
);
public LibraryCategoryItem()
{
InitializeComponent();
}
public string CategoryText
{
get => (string)GetValue(CategoryTextProperty);
set => SetValue(CategoryTextProperty, value);
}
public ImageSource IconSource
{
get => (ImageSource)GetValue(IconSourceProperty);
set => SetValue(IconSourceProperty, value);
}
private static void CategoryTextChanged(BindableObject bindable, object oldValue, object newValue)
{
var control = (LibraryCategoryItem)bindable;
control.CategoryLabel.Text = (string)newValue;
}
private static void IconSourceChanged(BindableObject bindable, object oldValue, object newValue)
{
var control = (LibraryCategoryItem)bindable;
control.IconImage.Source = (ImageSource)newValue;
}
}
}