© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago
Mek

✅ How to set a classname based off view model boolean avalonia

<TextBlock Classes="{Binding IsError ? Error : NewUserInput}" ... />
<TextBlock Classes="{Binding IsError ? Error : NewUserInput}" ... />
public CreateNewUserViewModel()
{
    private bool _isError = false;

    public UserModel ReturnUser()
    {
        bool usernameValid = ValidateUsername(Username);
        bool createPasswordValid = ValidatePassword(CreatePassword);
        bool confirmPasswordValid = ValidatePassword(ConfirmPassword);
        bool passwordsMatch = CreatePassword == ConfirmPassword;

        if (!usernameValid)
        {
            IsError = true;
            ErrorText = "...";
        }
    }
}
public CreateNewUserViewModel()
{
    private bool _isError = false;

    public UserModel ReturnUser()
    {
        bool usernameValid = ValidateUsername(Username);
        bool createPasswordValid = ValidatePassword(CreatePassword);
        bool confirmPasswordValid = ValidatePassword(ConfirmPassword);
        bool passwordsMatch = CreatePassword == ConfirmPassword;

        if (!usernameValid)
        {
            IsError = true;
            ErrorText = "...";
        }
    }
}
I have a TextBox in my axaml page that I'm trying to conditionally render styles based off the
IsError
IsError
value. I believe I have tried to do this before and got help with it, but I cannot find the thread for it as the search bar is not working properly for some reason and shows the most recent, oldes, and relevant as one of the first 5 threads I ever created here. Any help is appreciated. thank you.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Item Returning Null From View Model??? Avalonia
C#CC# / help
2y ago
❔ how to set a background color from resource in avalonia ?
C#CC# / help
4y ago
✅ Boolean values in AvaloniaUI
C#CC# / help
6d ago
How To Set Vertical Snap Points on Avalonia ScrollViewer
C#CC# / help
2y ago