Code Monkey home page Code Monkey logo

Comments (4)

vnbaaij avatar vnbaaij commented on July 4, 2024

Please supply us with ready-to-run reproduction code in the form of something we can copy/paste, a (zipped) project structure or a GitHub repository.

We do not have capacity to craft or compose a reproduction for every issue that gets raised.

If no code or repository is provided, this issue will get closed in 3 days

Help us to help you. Thanks.

from fluentui-blazor.

denispaluca avatar denispaluca commented on July 4, 2024

@vnbaaij Apperantly when you pass a value using ToString, it does not work correctly.
Example as above

@using Microsoft.FluentUI.AspNetCore.Components

<FluentTextField
    Value="@_value.ToString()"
    ValueChanged="@ChangeValue" />

@code {
    private RandEnum _value;

    private void ChangeValue(string newValue)
    {
        switch(newValue)
        {
            case "A":
                _value = RandEnum.A;
                break;
            case "C":
                _value = RandEnum.C;
                break;
            default:
                _value = RandEnum.A;
                break;
        }
    }

    public enum RandEnum {
        A,
        B,
        C
    }
}

from fluentui-blazor.

vnbaaij avatar vnbaaij commented on July 4, 2024

Yeah, I'm not surprised this is not working. _value is of type enum where as TextField only supports binding to a string. This should not even compile...

from fluentui-blazor.

vnbaaij avatar vnbaaij commented on July 4, 2024

If you change the code to this, it sort of works:

@using Microsoft.FluentUI.AspNetCore.Components

<FluentTextField Value="@_value.ToString()"
                 ValueChanged="@ChangeValue" ValueExpression="@(() => s)" />

@code {
    private RandEnum _value;
    private  string? s;

    private void ChangeValue(string newValue)
    {
        s = string.Empty;
        switch (newValue)
        {
            case "A":
                _value = RandEnum.A;
                break;
            case "C":
                _value = RandEnum.C;
                break;
            default:
                _value = RandEnum.A;
                break;
        }
        s = _value.ToString();
    }

    public enum RandEnum
    {
        A,
        B,
        C
    }
}

With 'sort of' I mean it works if you change for A->xyz->C->ghj->etc. If you just change from ne value that resolves to A to another that resolves to A again, the field will not update.

As this is a bit of a strange usage, I'm closing this issue. Hope the provided code will help you further.

from fluentui-blazor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.