I'm creating a project in .Net MAUI for IOS I've tested the operation on Android and it hasn't given me any problems, when I tried it on IOS it has been the opposite. I have an ImagenButton which works and triggers the command while on IOS it doesn't. The error is as follows:
Microsoft.Maui.Controls.Xaml.Diagnostics.BindingDiagnostics: Warning: 'BindingContext' property not found on 'formaciones.ViewModels.Formacion.ActoViewModel', target property: 'Microsoft.Maui.Controls.ImageButton.Command'
And on the screen I get the button but even if I tap it doesn't do anything.
Here's the button in the view:
<telerik:DataGridTemplateColumn HeaderText="" IsVisible="True">
<telerik:DataGridTemplateColumn.CellContentTemplate>
<DataTemplate x:DataType="vmodels:ActoViewModel">
<ImageButton x:Name="elimina" Command="{Binding BindingContext.SelectionCommand, Source={x:Reference ActosL}}"
CommandParameter="{Binding IdActo}"
WidthRequest="26" HeightRequest="26"
IsEnabled="True">
<ImageButton.Source>
<FontImageSource FontFamily="Iconsj" Glyph="" Color="LightCoral"/>
</ImageButton.Source>
</ImageButton>
</DataTemplate>
</telerik:DataGridTemplateColumn.CellContentTemplate>
</telerik:DataGridTemplateColumn>
In the view code:
public ActoView() {
InitializeComponent();
vm = new ActoViewModel(this, new LocalDbService());
BindingContext = vm;
}
and in the viewModel:
public ICommand SelectionCommand { get; }
public ActoViewModel()
{
}
public ActoViewModel(Page currentPage, LocalDbService dbService)
{
database = dbService;
_currentPage = currentPage;
LoadData();
CargaTitulo();
SelectionCommand = new Command(async (idActo) => await GuardarIdAc(idActo));
}
public async Task GuardarIdAc(object idActo)
{
IdActo = int.Parse(idActo.ToString());
}
I've tried to move the button but even if I put it inside another grid it doesn't work
The error is from my grid, in Adroid I can tap the button but in IOS can't
<Grid>
<Grid RowDefinitions="*">
<Grid ColumnDefinitions="*,*,*,*" Margin="10">
</Grid>
<Grid Grid.Row="0">
<telerik:RadDataGrid x:Name="dataGrid"
ItemsSource="{Binding Source}"
AutoGenerateColumns="False"
BackgroundColor="AliceBlue"
SelectionMode="None">
<telerik:RadDataGrid.Columns>
<telerik:DataGridDateColumn PropertyName="FechaInicio" HeaderText="Fecha" CanUserFilter="False"/>
<telerik:DataGridTextColumn PropertyName="Acto" HeaderText="Formacion" CanUserFilter="False"/>
<telerik:DataGridNumericalColumn PropertyName="IdActo" HeaderText="id" IsVisible="False" CanUserFilter="False"/>
<telerik:DataGridTemplateColumn HeaderText="" IsVisible="True">
<telerik:DataGridTemplateColumn.CellContentTemplate>
<DataTemplate>
<ImageButton x:Name="modificar"
Command="{Binding BindingContext.SelectionCommand3, Source={x:Reference Actos}}"
CommandParameter="{Binding IdActo}"
WidthRequest="26"
HeightRequest="26"
IsEnabled="True">
<ImageButton.Source>
<FontImageSource FontFamily="Iconsj" Glyph="" Color="Grey"/>
</ImageButton.Source>
</ImageButton>
</DataTemplate>
</telerik:DataGridTemplateColumn.CellContentTemplate>
</telerik:DataGridTemplateColumn>
<telerik:DataGridTemplateColumn HeaderText="" IsVisible="True">
<telerik:DataGridTemplateColumn.CellContentTemplate>
<DataTemplate>
<ImageButton x:Name="elimina"
Command="{Binding BindingContext.SelectionCommand2, Source={x:Reference Actos}}"
CommandParameter="{Binding IdActo}"
WidthRequest="26"
HeightRequest="26"
IsEnabled="True">
<ImageButton.Source>
<FontImageSource FontFamily="Iconsj" Glyph="" Color="LightCoral"/>
</ImageButton.Source>
</ImageButton>
</DataTemplate>
</telerik:DataGridTemplateColumn.CellContentTemplate>
</telerik:DataGridTemplateColumn>
<telerik:DataGridTemplateColumn HeaderText="">
<telerik:DataGridTemplateColumn.CellContentTemplate>
<DataTemplate>
<ImageButton x:Name="SelectedButton"
Command="{Binding BindingContext.SelectionCommand, Source={x:Reference Actos}}"
CommandParameter="{Binding IdActo}"
WidthRequest="26"
HeightRequest="26"
IsEnabled="True">
<ImageButton.Source>
<FontImageSource FontFamily="Iconsj" Glyph="" Color="Green"/>
</ImageButton.Source>
</ImageButton>
</DataTemplate>
</telerik:DataGridTemplateColumn.CellContentTemplate>
</telerik:DataGridTemplateColumn>
</telerik:RadDataGrid.Columns>
</telerik:RadDataGrid>
</Grid>
</Grid>
if I put the button for example in a <Shell.TitleView> it works for me.
the solution was that the telerik:RadDataGrid
created a format and clashed with the normal Grid so I deleted the Grid and it worked