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.
47 lines
1.3 KiB
47 lines
1.3 KiB
namespace MauiSpark.Vues;
|
|
|
|
public partial class JetonVue : ContentView
|
|
{
|
|
public static readonly BindableProperty CouleurPropriete = BindableProperty.Create(nameof(Couleur), typeof(Color), typeof(JetonVue), default(Color), propertyChanged: QuandCouleurChange);
|
|
|
|
public Color? Couleur
|
|
{
|
|
get => (Color?)GetValue(CouleurPropriete);
|
|
set => SetValue(CouleurPropriete, value);
|
|
}
|
|
|
|
public JetonVue()
|
|
{
|
|
InitializeComponent();
|
|
BindingContext = this;
|
|
}
|
|
|
|
private void QuandTailleChangee(object sender, EventArgs e)
|
|
{
|
|
double taille = Math.Min(Grid.Width, Grid.Height) / 2;
|
|
Cercle.WidthRequest = Cercle.HeightRequest = taille;
|
|
}
|
|
|
|
private static void QuandCouleurChange(BindableObject bindable, object oldValue, object newValue)
|
|
{
|
|
var view = bindable as JetonVue;
|
|
if (view != null)
|
|
{
|
|
view.UpdateCouleur();
|
|
}
|
|
}
|
|
|
|
private void UpdateCouleur()
|
|
{
|
|
// Gérer la couleur null
|
|
if (Couleur == null)
|
|
{
|
|
// Définir une couleur par défaut si null
|
|
BackgroundColor = Colors.Transparent; // Ou toute autre couleur par défaut
|
|
}
|
|
else
|
|
{
|
|
BackgroundColor = Couleur;
|
|
}
|
|
}
|
|
} |