Inside List Item button ActionText not showing after adding BindingContext on Button. after removing the BindingContext from Button then ActionText showing,but on button click event not working.
<ListView x:Name="ShipmentData"
HasUnevenRows="True" ItemsSource="{Binding ShipmentData}" SelectedItem="{Binding SelectedShippedItem}"
BackgroundColor="White">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Margin="0" Padding="5" x:Name="Item">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Text="{Binding ShipTransId}" Grid.Row="0" IsVisible="False"/>
<Label Text="{Binding LabelUri}" Grid.Row="0" IsVisible="False"/>
<Label Text="{Binding OrderNumber}" Grid.Row="0" Grid.Column="0" HorizontalTextAlignment="Center"/>
<Label Text="{Binding ShippingId}" Grid.Row="0" Grid.Column="1" HorizontalTextAlignment="Center"/>
<Label Text="{Binding Status}" Grid.Row="0" Grid.Column="2"
HorizontalTextAlignment="Center" HorizontalOptions="Center" VerticalOptions="Center"/>
<Button Text="{Binding ShipmentData.ActionText}" VerticalOptions="Center"
HorizontalOptions="Center" BorderRadius="10"
Command="{Binding PrintLabel}" Grid.Row="0" Grid.Column="3" Margin="5,0,0,0"
BindingContext="{Binding Source={x:Reference ShipmentData}, Path=BindingContext}"
CommandParameter="{Binding Source={x:Reference Item}, Path=BindingContext}"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.Behaviors>
<eventToCommand:EventToCommandBehavior EventName="ItemTapped" Command="ShippedItemTapped"/>
</ListView.Behaviors>
</ListView>
Here is my PageModel
public ObservableCollection<ShowShipmentData> ShipmentData
{
get { return _shipmentData; }
set
{
_shipmentData = value;
RaisePropertyChanged();
}
}
ShipmentData = DependencyService.Get<ISQLite2().ShowShipmentTableData(GlobalVariable.BranchId);
public Command PrintLabel
{
get
{
return new Command(async (e) =>
{
ShowShipmentData selecedItem = (e as ShowShipmentData);
});
}
}
How to solve this?
<Button Text="{Binding ActionText}"
– Gerald Versluis