Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microsoft.Maui.Controls.BindableObject: Warning: Value is an invalid value for Maximum #217

Open
PuppyLo opened this issue Jan 28, 2025 · 4 comments

Comments

@PuppyLo
Copy link

PuppyLo commented Jan 28, 2025

I'm new to MAUI.

This error keeps popping up:

Microsoft.Maui.Controls.BindableObject: Warning: Value is an invalid value for Maximum’ 

Trace.WriteLine($‘PaginationStepper Maximum: {DataGrid.PageCountProperty.DefaultValue}’ gives ‘PaginationStepper Maximum: 1’.

Can you tell me what to do?

<datagrid:DataGrid ItemsSource="{Binding TradeDataGrid}" PaginationEnabled="False" PageNumber="1" PageSize="5" >
            <datagrid:DataGrid.Columns>
                <datagrid:DataGridColumn Title="USDT" PropertyName="[0]" />
                <datagrid:DataGridColumn Title="BTC" PropertyName="[1]" />
                <datagrid:DataGridColumn Title="USDD" PropertyName="[2]" />
                <datagrid:DataGridColumn Title="HTX" PropertyName="[3]" />
                <datagrid:DataGridColumn Title="TRX" PropertyName="[4]" />
                <datagrid:DataGridColumn Title="ETH" PropertyName="[5]" />
                <datagrid:DataGridColumn Title="XRP" PropertyName="[6]" />
                <datagrid:DataGridColumn Title="LTC" PropertyName="[7]" />
            </datagrid:DataGrid.Columns>
        </datagrid:DataGrid>
@PuppyLo
Copy link
Author

PuppyLo commented Jan 28, 2025

Here's a piece of code just in case

 private void UpdateGrid(List<List<string>> allData)
 {
     try
     {

         for (int i = 0; i < 10; i++)
         {
             var row = new List<string>();
             foreach (var currencyData in allData)
             {
                 row.Add(i < currencyData.Count ? currencyData[i] : "");
             }

             Trace.WriteLine($"PaginationStepper Maximum: {DataGrid.PageCountProperty.DefaultValue}");

             TradeDataGrid.Clear();


             TradeDataGrid.Add(row);
         }
     }
     catch(Exception ex)
     {
         Trace.WriteLine(ex);
     }
 }

@symbiogenesis
Copy link
Collaborator

Seems like there could be bugs in both this control and your usage.

I see you set PaginationEnabled="False" and it still throws this error even when disabled?

Setting an invalid page number should probably fallback to a reasonable value, instead of failing. An erroneously low value should default to 1, and an erroneously high value should default to the last page. And a hardcoded value of 1 should never fail, even when there are no records.

I will review the code to ensure this is the case. Until then, I recommend just removing the PageNumber="1" attribute unless there's a strong reason to need it.

@PuppyLo
Copy link
Author

PuppyLo commented Jan 29, 2025

I added these attributes just to see if the error would go away but no, tried different options but nothing worked.
Initially it was just <datagrid:DataGrid ItemsSource=‘{Binding TradeDataGrid}’ >

@symbiogenesis
Copy link
Collaborator

It is possible the error is not coming from the DataGrid at all.

Also, the use of the square brackets to define the property names for the columns is unlikely to work. Although the error you showed seems unrelated.

Make a normal collection and define the properties that way. You can also use sub-properties with a dot as the defined PropertyName.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants