3
いくつかの値でenumを宣言しました。私はFormatedパラメータに渡したいと思います。ここに私のC#のコードは次のとおりです。xamarin forms列挙型の値をXAMLに渡してswitch文で使用する方法は?
public MyControllerView()
{
ContentEntry.TextChanged += Entry_TextChanged;
}
public string Formated
{
get
{
return formatedText;
}
set
{
formatedText = value;
}
}
public enum FomationType
{
NameValidation,
CardNrValidation,
ExpDate
};
// here I want to use my enum in switch statement, but I can't, because I can't modify my method parameters
private void Entry_TextChanged(object sender, TextChangedEventArgs e)
{
FomationType FomationType;
switch (FomationType)
{
case FomationType.NameValidation:
ToUpper(ent);
break;
case FomationType.CardNrValidation:
CardNumberValidation(ent);
break;
case FomationType.ExpDate:
ExpDate(ent, e);
break;
}
}
そして、ここで私は私の列挙型の値を渡す必要がフォーマットされたパラメータを使用して、私のXAMLコードです:
<ContentPage.Content>
<StackLayout Padding="7,7,7,7" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Spacing="0">
<cv:MyControllerView LabelText="some text 4" Placeholder="some text 4" Formated="" Keyboard="Text" >
</cv:MyControllerView>
<cv:MyControllerView LabelText="some text 3" Placeholder="some text 3" Formated="" Keyboard="Numeric" >
</cv:MyControllerView>
<cv:MyControllerView LabelText="some text 2" Placeholder="some text 2" Formated="" Keyboard="Numeric" >
</cv:MyControllerView>
</StackLayout>
</ContentPage.Content>
は現在、いくつかの私は渡すべきかFormationType anumフォーマットさに=」パラメータ。そして私は、列挙型の値にフォーミュレートされた文字列を割り当てる必要がありますか?