Pass parameters in Command Xamarin

theocangtheocang Member ✭✭✭

I have this view :

<StackLayout> <ListView ItemsSource="{Binding DatasModels}" x:Name="listViewDatas" ItemSelected="Handle_ItemSelected"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <StackLayout Orientation="Horizontal"> <Label Text="{Binding firstname}"/> <Label Text="{Binding lastname}"/> </StackLayout> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView> <StackLayout Orientation="Horizontal"> <Button BackgroundColor="Maroon" Text="Add" Command="{Binding AddDataJson}" CommandParameter="{Binding Source={x:Reference entry}, Path=Text}"/> </StackLayout> </StackLayout>

This viewModel :

public ICommand AddDataJson { get; private set; }

public listViewMenuModels()
        AddDataJson = new Command<string>(addDataJson);

    private void addDataJson(string stringUpdate)


So in the view, the x:reference doesn't work. It don't find the reference.
I have try without a listview and it's works. But the listview be problematic.




Sign In or Register to comment.