为什么 ImageButton 对我不起作用?网格 IOS Telerik

问题描述 投票:0回答:1

我正在为 IOS 在 .Net MAUI 中创建一个项目,我已经在 Android 上测试了操作,它没有给我带来任何问题,当我在 IOS 上尝试时,情况恰恰相反。我有一个 ImagenButton 可以工作并触发命令,而在 IOS 上却不能。错误如下:

Microsoft.Maui.Controls.Xaml.Diagnostics.BindingDiagnostics: Warning: 'BindingContext' property not found on 'formaciones.ViewModels.Formacion.ActoViewModel', target property: 'Microsoft.Maui.Controls.ImageButton.Command'

在屏幕上我看到了按钮,但即使我点击它也没有任何反应。

这是视图中的按钮:

<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>

查看代码中:

public ActoView() {      
    InitializeComponent();
    vm = new ActoViewModel(this, new LocalDbService());
    BindingContext = vm; 
}

在视图模型中:

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());
}

我尝试移动按钮,但即使我将其放入另一个网格中也不起作用

错误来自我的网格,在 Adroid 中我可以点击按钮,但在 IOS 中不能

<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="&#xE802;" 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="&#xE801;" 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="&#xF064;" Color="Green"/>
                                </ImageButton.Source>
                            </ImageButton>
                        </DataTemplate>
                    </telerik:DataGridTemplateColumn.CellContentTemplate>
                </telerik:DataGridTemplateColumn>
            </telerik:RadDataGrid.Columns>
        </telerik:RadDataGrid>
    </Grid>
</Grid>

如果我将按钮放在 中,它对我有用。

c# ios xaml telerik maui
1个回答
0
投票

解决方案是 telerik:RadDataGrid 创建了一种格式并与普通网格发生冲突,所以我删除了网格并且它起作用了

© www.soinside.com 2019 - 2024. All rights reserved.