C
C#10mo ago
Mekasu0124

✅ 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 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.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server