Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I hold ENUM of statuses, with the goal being that for each status other buttons are enabled.
I mean connect the 'isEnable' property to the status, but the status is not Boolean ... how do I define it?

What I have tried:

C#:
I made the status 'DependencyProperty', so that it 'notifies' of a change: 

public static readonly DependencyProperty DroneStatusProperty =
        DependencyProperty.Register("DroneStatus",
               typeof(object),
               typeof(drone_pl),
               new UIPropertyMetadata(0));
        public Enum_pl.DroneStatuses DroneStatus
        {
            get { return (Enum_pl.DroneStatuses)GetValue(DroneStatusProperty); }
            set { SetValue(DroneStatusProperty, value); }
        }


and that's my buttons - XML:
<Button IsEnabled="{Binding Path=DroneStatus ???, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource myButtonGroup1}" Grid.Column="0" Name="SendDroneToCharge" Content="SEND TO CHARGE" Click="SendDroneToChargeClick"/>

and so on...
Posted
Updated 13-Feb-22 19:54pm
v2
Comments
Graeme_Grant 13-Feb-22 20:04pm    
The code posted looks random and not related to the question. Please use the Improve Question button and update with more information including what you have tried so far.

1 solution

Add a "proxy" property to your "data context", and bind that to the button (in the xaml); e.g.

public bool IsDroneEnabled => DroneStatus == xxx;

... Binding Path=IsDroneEnabled
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900