Dmitry
Dmitry

Reputation: 315

C# Xamarin Variable to XAML

I have a list of names and if I click on one it will open ActionSheet Dialogue (Open, Edit, Delete)

var action = await DisplayActionSheet("Choose action:", "Cancel", null, "Open", "Edit", "Delete");
switch (action)
{
    case "Open":
        wait Navigation.PushAsync(new NamePageOpen(e.Appointment as Models.Event, Callback));
        break;
    case "Edit":                
        await Navigation.PushAsync(new NamePageEdit(e.Appointment as Models.Event, Callback));
        break;
    case "Delete":
        await Navigation.PushAsync(new NamePageDelete(e.Appointment as Models.Event, Callback));
        break;
    default:
        break;
}

After action choose it will open one of content page with XAML like:

<StackLayout Padding="5,5,5,5">
    <Label Text="Name"/>
    <Entry Text="{Binding Title}"/>

    <Label Text="Detail"/>
    <Editor Text="{Binding Detail}" HeightRequest="100"/>
</StackLayout>

I want to add new field Type and use some more actions (Open1, Open2, Open3).

<Label Text="Type"/>
<Entry Text="{Binding Type}"/> 

But I want to use the same content page. Is it possible to get value (1,2,3) in field Type which will depend on chosen action in display action sheet?

Hope for help.

Upvotes: 1

Views: 129

Answers (1)

Neil
Neil

Reputation: 11929

I would recommend you don't try and reuse pages in this manner. You might think reusing is a good idea today, but in 3 months time, when this duplication is no longer correct, you will have to split the pages/views/models etc. Best to do it now and save yourself some headaches down the road.

Upvotes: 1

Related Questions