Ivanik

Ivanik

  • 920
  • 811
  • 224

binding property shadows net maui android

Aug 29 2024 12:10 PM

good morning everyone, sorry but I'm a very very newbie and I don't even know how to ask the right questions.

I wanted to ask if there is a possibility to create a binding for the shadow properties of a control (eg. a button)

Something that could look like this. thanks to everyone.

 


public class shadow
{
    public string brush { get; set; } = "Black";
    public string offset { get; set; } = "20,20";
    public string radius { get; set; } = "10";
    public string opacity { get; set; } = "0.7";
}


<Button
       x:Name="CounterBtn"
       Text="Click me" 
       SemanticProperties.Hint="Counts the number of times you click"
       Clicked="OnCounterClicked"
       BorderColor="DarkBlue"
       BorderWidth="1"
       HorizontalOptions="Fill" >
   <Button.Shadow>
      <Shadow Brush="{Binding brush}}"
              Offset="{Binding offset}"
              Radius="{Binding radius}"
              Opacity="{Binding opacity}" />
   </Button.Shadow>
</Button>

public class shadow

{ public string brush { get; set; } = "Black"; public string offset { get; set; } = "20,20"; public string radius { get; set; } = "10"; public string opacity { get; set; } = "0.7"; } <Button x:Name="CounterBtn" Text="Click me" SemanticProperties.Hint="Counts the number of times you click" Clicked="OnCounterClicked" BorderColor="DarkBlue" BorderWidth="1" HorizontalOptions="Fill" > <Button.Shadow> <Shadow Brush="{Binding brush}}" Offset="{Binding offset}" Radius="{Binding radius}" Opacity="{Binding opacity}" /> </Button.Shadow> </Button> ```


Answers (2)