Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Binding to enumerated types with x:Static (ConverterParameter)

$
0
0

Hi Xamarin Experts,

I have the following button:

<Button x:Name="GoButton"
            Text="GO"
            FontSize="40"
            Grid.Column="0"
            Grid.Row="0"
            HorizontalOptions="CenterAndExpand"
            VerticalOptions="CenterAndExpand"
            IsVisible="{Binding GameState,
                         Converter={StaticResource GameStateEqualityConverter},
                         ConverterParameter={x:Static local:GameEngine.State.WAITING_FOR_PLAYER_TO_START}}"/>

My GameEngine has an enum in it, but it's not being found with how my ConverterParameter is referencing it. How does one reference enums within ConverterParameter? When I change the enum to a static int, I can just reference it with local:GameEngine.WAITING_FOR_PLAYER_TO_START, so it looks like it doesn't like the dot notation....

This is how the enum is declared. It should be visible outside the class. What am I doing wrong?

public class GameEngine: INotifyPropertyChanged
 {
     public enum State
     {
         WAITING_FOR_PLAYER_TO_START,
         GAME_OVER,
     };
     ....

Thanks!
Mike


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>