dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.02k stars 1.73k forks source link

MAUI Picker Behavior Discrepancy Between Material Design PickerField and Standard Picker in Xamarin.Forms Tab Navigation #23256

Closed vsfeedback closed 2 months ago

vsfeedback commented 3 months ago

This issue has been moved from a ticket on Developer Community.


In my Xamarin.Forms application, I'm encountering differing behavior between and controls when binding to the Type property and navigating between tabs.

public class ColumnEntity : ObservableObject
{
    private string _type;
    public string Type
    {
        get => _type;
        set
        {
            if (_type != value)
            {
                _type = value;
                OnPropertyChanged(nameof(Type));
                UpdateVisibilityProperties();
            }
        }
    }

[ObservableProperty]
    public ObservableCollection<string> ColumnTypes = new ObservableCollection<string>
    {
        "string",
        "int",
        "DateTime",
        "bool",
        "decimal",
        "Enum"
    };

private bool _isMaxLengthVisible;
    public bool IsMaxLengthVisible
    {
        get => _isMaxLengthVisible;
        set
        {
            if (_isMaxLengthVisible != value)
            {
                _isMaxLengthVisible = value;
                OnPropertyChanged(nameof(IsMaxLengthVisible));
            }
        }
    }

private void UpdateVisibilityProperties()
    {
        IsMaxLengthVisible = Type == "string" || Type == "decimal";
        // Add more visibility logic as needed
    }
}

<material:TabItem Title="Configurazione proprietà">
    <material:TabItem.Content>
        <Grid RowSpacing="15" RowDefinitions="Auto, Auto">
            <!-- Other UI elements -->
            <material:PickerField Grid.Row="1" Grid.Column="2" x:Name="PickerType"
                                  ItemsSource="{Binding ColumnTypes}" SelectedItem="{Binding Type, Mode=TwoWay}"
                                  BorderColor="Transparent" SelectedValueChanged="OnPickerCompleted"/>
            <!-- OR -->
            <!--<Picker TitleColor="Black" x:Name="PickerType" Grid.Row="1" Grid.Column="2"
                    SelectedItem="{Binding Type, Mode=TwoWay}" SelectedIndexChanged="OnPickerCompleted"
                    ItemsSource="{Binding ColumnTypes}" />-->

<Label Grid.Row="0" Grid.Column="3" Padding="2,0,0,0" Text="Dimensioni" FontSize="13" TextColor="#8a8888"
                   IsVisible="{Binding IsMaxLengthVisible}" />
            <Entry Grid.Row="1" Grid.Column="3" x:Name="MaxLength" Text="{Binding MaxLength, Mode=TwoWay}"
                   IsVisible="{Binding IsMaxLengthVisible}" Keyboard="Numeric" Completed="OnEntryCompleted">
                <Entry.Behaviors>
                    <behaviors:DecimalOnlyBehavior />
                </Entry.Behaviors>
            </Entry>
        </Grid>
    </material:TabItem.Content>
</material:TabItem>

Using , the Type property reliably retains its selected value during tab navigation. Using , the Type property inconsistently loses its selected value.


Original Comments

Feedback Bot on 6/13/2024, 08:01 PM:

(private comment, text removed)


Original Solutions

(no solutions)

github-actions[bot] commented 3 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

dotnet-policy-service[bot] commented 2 months ago

Hi @vsfeedback. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

dotnet-policy-service[bot] commented 2 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback to reproduce the issue but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.