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

MaterialTextField Choices with dynamic data #74

Closed
rotsen24154 opened this issue Feb 19, 2019 · 4 comments
Closed

MaterialTextField Choices with dynamic data #74

rotsen24154 opened this issue Feb 19, 2019 · 4 comments
Labels
bug Something isn't working valid This issue/bug/feature request is valid

Comments

@rotsen24154
Copy link

rotsen24154 commented Feb 19, 2019

I have two MaterialTextField, the first has a string's list attached on Choices property and the other one depends of that value to be filled with another string's list (At the beginning this list is empty). But if I choice the first option and try to select the second option throws this exception "The property Choices is null or empty", even though the ObservableCollection of the second MaterialTextField was filled after choice the first option.

With the previous nuget works fine.

@contrix09
Copy link

Hi. Can you provide a sample code of how to replicate this?

@rotsen24154
Copy link
Author

There is a example project.
Link example project

@rotsen24154
Copy link
Author

I could not create a pull request, but I solved doing this on MaterialTextField.xaml.cs

private void SetControl()
{
    trailingIcon.TintColor = this.TextColor;
    persistentUnderline.Color = this.UnderlineColor;
    tapGesture.Command = new Command(() =>
    {
        if (!entry.IsFocused)
        {
            entry.Focus();
        }
    });

    mainTapGesture.Command = new Command(async () =>
    {
        if (Choices == null || Choices?.Count <= 0)
        {
            throw new InvalidOperationException("The property `Choices` is null or empty");
        }
        _choices = GetChoices();

        var result = await MaterialDialog.Instance.SelectChoiceAsync("Select an item", _choices);

        if (result >= 0)
        {
            this.Text = _choices[result];
        }
    });
}

@contrix09
Copy link

contrix09 commented Feb 19, 2019

Ok thanks. I'll apply this fix myself.

@contrix09 contrix09 self-assigned this Feb 20, 2019
@contrix09 contrix09 added bug Something isn't working valid This issue/bug/feature request is valid labels Feb 20, 2019
@contrix09 contrix09 removed their assignment Sep 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working valid This issue/bug/feature request is valid
Projects
None yet
Development

No branches or pull requests

1 participant