enisn / Xamarin.Forms.InputKit

CheckBox, Radio Button, Labeled Slider, Dropdowns etc.
MIT License
579 stars 98 forks source link

According to the example, MVVM binding cannot be implemented and the result after binding cannot be obtained. #329

Closed 5118234 closed 1 year ago

5118234 commented 1 year ago

When I run the example using MAUI, I cannot obtain the property value in the ViewModel after the validation is passed. I don't know whether the usage method is wrong or the component has a bug The current version of InputKit. Maui is 4.2 My English is not good, this is the use of machine translation. thank you

  <input:AdvancedEntry
                        Title="account:"                        
                        IconImage="{material:Icon Icon=SupervisorAccount}"                      
                        TitleColor="#000"
                        CornerRadius="5"
                        HeightRequest="90"
                        TextFontSize="18"
                        Margin="0,10,0,0"
                        Padding="0,0,0,0"
                        Placeholder="input account"
                        PlaceholderColor="LightGray"
                        **Text="{Binding UserName}"**
                        TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}"
                        ValidationPosition="Before">
                        <input:AdvancedEntry.Validations>
                            <validation:RequiredValidation  Message="must input"/>
                        </input:AdvancedEntry.Validations>
                    </input:AdvancedEntry>
viewmodel
    string userName;
    public string UserName {
            set
            {
                if (userName != value)
                {
                    userName = value;
                    OnPropertyChanged(nameof(UserName));
                }
            }
            get => userName;
        }

async void Submit() { if (!IsValidated) { var result=UserName; ### // After verification, the value of UserName is null }